• 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));
  • 相关阅读:
    车载导航系统中GPS的定位
    《开源框架那点事儿25》:对框架模板引擎实现方式的改造实录
    Mysql insert语句的优化
    Codeforces 475 D. CGCDSSQ
    提高代码编码的效率,习惯非常重要!
    ubuntu14.04 安装LNMP
    Unity3d数据加密
    第14章3节《MonkeyRunner源代码剖析》 HierarchyViewer实现原理-HierarchyViewer实例化
    Polyfill简介
    只在需要的时候 Polyfill 你的 JavaScript 代码
  • 原文地址:https://www.cnblogs.com/dwf07223/p/3026922.html
Copyright © 2020-2023  润新知