Snippets

Piotr Szrajber Geospatial Portal - All values of the 'POP' attribute from 'USSample|States' (WMPS)

Created by Piotr Szrajber
/**
* Get all values of the 'POP' attribute from 'USSample|States' feature class in WMPS service
* Warning: This snippet will work for "feature classes", rather not for "maps"
* 2017-03-01 Piotr Szrajber <piotr.szrajber@hexagongeospatial.com>
*/

var url = "http://demo.hexagongeospatial.com/wmps/mapService.svc",
    featureClassId = "USSample|States",
    applicationId = "DEMO_USA"

$GP.services.add({
    url: url,
    featureClassId: featureClassId,
    applicationId: applicationId,
    definitionName: "MapPublisher"
}, function(result1) {
    $GP.edit.getAttributeList({
        mapServiceId: result1.mapServiceId,
        featureClassId: featureClassId
    }, function(result3) {
        $GP.edit.getAttributeValues({
            mapServiceId: result1.mapServiceId,
            featureClassId: featureClassId,
            attributeId: "POP",
            start: 0,
            limit: 100
        }, function(result4) {
            var valueList = result4.values.map(function(x) {
                return x.value;
            });
            $GP.ui.info($GP.utils.serialize(valueList));
        }, function(result4) {
            $GP.ui.info(result4.msg || result4.message);
        });
    }, function(result3) {
        $GP.ui.info(result3.msg || result3.message);
    });
}, function(result1) {
    $GP.ui.info(result1.msg || result1.message);
});

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.