zoukankan      html  css  js  c++  java
  • ArcGIS JavaScript API 添加点

    function ShowStationOnMap(stations) {

         // 清除图中的元素    

      map.graphics.clear();

          // 设置显示中心点及坐标

      var location = new esri.geometry.Point(stations[0].longtitude, stations[0].latitude, map.spatialReference)    

      map.centerAndZoom(location, 8);

          // 逐个添加元素

          for (var s = 0; s < stations.length; s++) {        

           var symbol = new esri.symbol.PictureMarkerSymbol(stations[s].imageUrl, 18, 18);        

           var pt = new esri.geometry.Point(stations[s].longtitude, stations[s].latitude, map.spatialReference)

               // 每个元素的属性值     

           var attr = { "stationName": stations[s].stationName, "sId": stations[s].sId, "countryName": stations[s].countryName, "projectName": stations[s].projectName,                       "buildYear": stations[s].buildYear };   

               // 点击该元素时的信息窗  

           var infoTemplate = new esri.InfoTemplate("${stationName}", "站点编号: ${sId}<br/>所属项目: ${projectName}  <br/>所属区县: ${countryName}

                              <br/>建成年份:${buildYear}<div><a href='javascript:ShowDetailStationPanel(" + stations[s].sId + ")'>查看详情</a> </div>");        

               var graphic = new esri.Graphic(pt, symbol, attr, infoTemplate);        

               map.graphics.add(graphic);    

         }

    }

    当在外部点击一个点时在地图上显示该数据的信息窗 这里用的是 map.infoWindow 和 infoTemplate 有点区别

     var pt = new esri.geometry.Point(data.record.longtitude, data.record.latitude, map.spatialReference)        

     var attr = { "stationName": data.record.stationName, "sId": data.record.sId, "countryName": data.record.countryName, "projectName": data.record.projectName,

                       "buildYear": data.record.buildYear };

     var infoTemplate = new esri.InfoTemplate("${stationName}", "站点编号: ${sId}<br/>所属项目: ${projectName}  <br/>所属区县: ${projectName} <br/>建成年份:

                       ${buildYear}<div><a href='javascript:ShowDetailStationPanel(" + data.record.sId + ")'>查看详情</a> </div>");        

     var symbol = new esri.symbol.PictureMarkerSymbol(data.record.imageUrl, 18, 18);        

     var graphic = new esri.Graphic(pt, symbol, attr, infoTemplate);        

     map.infoWindow.setContent(graphic.getContent()); 

     map.infoWindow.setTitle(data.record.stationName);        

     map.infoWindow.show(pt, map.getInfoWindowAnchor(pt));

  • 相关阅读:
    Spring配置自动加载执行多次的解决方法
    获取Excel文件内容,0307通用
    将Json转实体
    将实体转换为map
    Json数据转Map
    获取随机字符串
    将长内容分割,用双主键进行存储
    解决win10开机出现C:WIndowssystem32configsystemprofileDesktop不可用 问题
    2016.2.22
    云中行走
  • 原文地址:https://www.cnblogs.com/oftenlin/p/2672186.html
Copyright © 2011-2022 走看看