ArcGIS-API-for-JavaScript地图服务打点功能

27次阅读

共计 1100 个字符,预计需要花费 3 分钟才能阅读完成。

arcgis 地图服务封装地图打点功能

1、初始化地图服务

            dojoRequire(["esri/map", 
            "esri/geometry/Point", ],(Map,Point,)=>{window.initPGISLayer()
            map = new Map("map", {center : new Point(113.417712153994512,23.224568881656335), // 中心点
                zoom : 8,
                logo : false,
                slider : false,
            })
            var sl_url = "http://10.41.219.142:6080/PGIS_S_TileMapServer/ags/vector/";
            mapLayer1 = new window.esri.layers.CCFPGISLayer(sl_url);
            map.addLayer(mapLayer1);
            this.drawPonit(data);
        })

2、绘制打点功能 drawPonit 方法

    drawPonit=(data)=>{
        dojoRequire([
            "esri/InfoTemplate",
            "esri/layers/GraphicsLayer",
            "esri/geometry/Point", 
            "esri/SpatialReference",
            "esri/symbols/PictureMarkerSymbol",
            "esri/graphic",
        ],(InfoTemplate,GraphicsLayer,Point,SpatialReference,PictureMarkerSymbol,Graphic)=>{drawLayer = new GraphicsLayer({opacity:0.80,id: "mapLayer"});
            map.addLayer(drawLayer,2);
            for(let i=0;i<data.length;i++){let mp = new Point(new SpatialReference({wkid:4326}));
                let infoTemplate;
                let attr = {};
                let sms = new PictureMarkerSymbol('./marker-icon.png',30,36);
                mp.points.push([[data[i].lng],[data[i].lat]]);
                infoTemplate = new InfoTemplate(data[i].title,data[i].content
                )
                let graphic = new Graphic(mp,sms,attr,infoTemplate);
                drawLayer.add(graphic);
            }
        })
    }

正文完
 0