第二篇 arcgis api for js 根据坐标生成点

要点

1、生成点要素

2、地图加载顺序及map.on事件顺序;

3、分析两种不同图层加载方式对点生成的影响;


可运行代码:

 
  

<%--
  Created by IntelliJ IDEA.
  User: neil
  Date: 2015/8/16
  Time: 18:48
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>



    
    
    SimpleMarkerSymbol with SVG Path - Simplified
    
    
    
    
    
    



注意,只有当map.on事件紧跟map=new Map(...);之后,才能正常显示点;

下面换成另一种方式加载瓦片图层,将上面方法代码替换如下:

                function(Map, Tiled,Point, SpatialReference, SimpleMarkerSymbol, Graphic) {
                    map = new Map("map");

                    map.on("load", function() { ShowLocation(113,37); });

                    var tiled = new Tiled("http://server.arcgisonline.com/arcgis/rest/services/World_Topo_Map/MapServer");
                    map.addLayer(tiled);



                    function ShowLocation(x, y) {
                        var point = new Point(x, y, new SpatialReference({wkid:4326}));
                        var simpleMarkerSymbol = new SimpleMarkerSymbol();
                        var graphic = new Graphic(point, simpleMarkerSymbol);

                        map.graphics.add(graphic);
                    };

采用第二种方式同样可以生成点。下面采用第三种方式,待续……




你可能感兴趣的:(GIS,ArcGIS,ArcGIS,API)