簡體   English   中英

Arcgis Esri地圖:收集pictureMarkerSymbols有關區域選擇的信息

[英]Arcgis Esri Map: Collect pictureMarkerSymbols info on area select

我正在嘗試創建一個地圖,可以在其中創建選擇區域,並獲取其下所有圖形指針的信息,我嘗試通過以下示例進行修改,但它們使用的是Web服務和查詢,並且我希望使用json或數組。

多數民眾贊成在示例http://developers.arcgis.com/javascript/samples/graphics_extent_query/我在關注

選擇后我想獲得指針的電子郵件地址。 這是一個小提琴http://bit.ly/1jwLazp開始。

我將您的小提琴與樣本結合在一起,產生了以下結果:

https://jsfiddle.net/gary4620/t9h513c7/17/

var map;
var s;
var gl;
var highlightSymbol;

require([
    "esri/map",
    "esri/geometry/Point",
    "esri/symbols/SimpleMarkerSymbol",
    "esri/graphic",
    "esri/layers/GraphicsLayer",
    "esri/toolbars/draw",
    "esri/symbols/SimpleMarkerSymbol",
    "esri/InfoTemplate",
    "dojo/domReady!"], function (
Map, Point, SimpleMarkerSymbol, Graphic, GraphicsLayer, Draw, SimpleMarkerSymbol, InfoTemplate) {
    function initToolbar(map) {
        var tb = new Draw(map);
        tb.on("draw-end", findPointsInExtent);
        tb.activate(Draw.EXTENT);
    }

    function findPointsInExtent(result) {
        var extent = result.geometry;
        var results = [];
        require(["dojo/_base/array"], function (array) {
            array.forEach(gl.graphics, function (graphic) {
                if (extent.contains(graphic.geometry)) {
                    graphic.setSymbol(highlightSymbol);
                    results.push(graphic.getContent());
                }
                //else if point was previously highlighted, reset its symbology
                else if (graphic.symbol == highlightSymbol) {
                    graphic.setSymbol(s);
                }
            });

            //TODO use results as needed; here we just print to console
            console.log("There are " + results.length + " results:");
            console.log(results.join(""));
        });
    }

    map = new Map("map", {
        basemap: "streets",
        center: [-88.21, 42.21],
        zoom: 10
    });
    map.on("load", function () {
        var content = 'email@address.com';
        gl = new GraphicsLayer();
        var p = new Point(-88.380801, 42.10560);
        s = new SimpleMarkerSymbol().setSize(20);
        var g = new Graphic(p, s, {
            'title': 'Title',
            'content': content
        }, new InfoTemplate('${title}', '${content}'));
        gl.add(g);
        map.addLayer(gl);

        initToolbar(this);
    });
    highlightSymbol = new SimpleMarkerSymbol().setColor(new dojo.Color([255,0,0]));
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM