第二篇 arcgis api for js 根据坐标生成点
2015-08-16 23:25
876 查看
要点
1、生成点要素
2、地图加载顺序及map.on事件顺序;
3、分析两种不同图层加载方式对点生成的影响;
可运行代码:
注意,只有当map.on事件紧跟map=new Map(...);之后,才能正常显示点;
下面换成另一种方式加载瓦片图层,将上面方法代码替换如下:
采用第二种方式同样可以生成点。下面采用第三种方式,待续……
1、生成点要素
2、地图加载顺序及map.on事件顺序;
3、分析两种不同图层加载方式对点生成的影响;
可运行代码:
</pre><pre>
<%-- 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" %> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"> <title>SimpleMarkerSymbol with SVG Path - Simplified</title> <link rel="stylesheet" href="http://js.arcgis.com/3.14/dijit/themes/claro/claro.css"> <link rel="stylesheet" href="http://js.arcgis.com/3.14/dojox/widget/ColorPicker/ColorPicker.css"> <link rel="stylesheet" href="http://js.arcgis.com/3.14/esri/css/esri.css"> <style> html, body, #map { height: 100%; width: 100%; margin: 0; padding: 0; } </style> <script src="http://js.arcgis.com/3.14/"></script> <script> var map; require([ "esri/map", "esri/geometry/Point", "esri/SpatialReference", "esri/symbols/SimpleMarkerSymbol", "esri/graphic" ], function(Map, Point, SpatialReference, SimpleMarkerSymbol, Graphic) { map = new Map("map", { basemap: "topo", center: [113, 37], zoom: 13 }); map.on("load", function() { ShowLocation(113,37); }); 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); }; }); </script> </head> <div id="map"></div> </body> </html>
注意,只有当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); };
采用第二种方式同样可以生成点。下面采用第三种方式,待续……
相关文章推荐
- IPv4地址与整型类型互转_Java_PHP_JavaScript
- javascript的简洁的写法
- js时间函数
- JavaScript语法概述
- 简单 js 验证
- Javascript模块化编程:require.js的用法
- JSBadgeView的使用
- JavaScript--点击颜色,为主题更换背景颜色
- JavaScript中的this代表什么?
- JavaScript--利用setInterval或setTimeout实现背景颜色轮播
- js中的事件
- JvaScript--使用js添加数据,点击按钮,将内容放入表格中
- 45种Javascript技巧大全
- JS设置 cookie,删除 cookie
- 【JavaScript】AJax
- Javascript 基础
- Javascript 基础
- hdu 1874 畅通工程续 dijsktra dijkstra+邻接表 优先队列 bellman-ford bellman-ford队列优化(基础题目,一步步优化)
- 不用js实现背景图片的切换
- JavaScript编程--任意输入一个数判断是不是闰年,数列求和练习