<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <link rel="stylesheet" type="text/css" href="http://192.168.1.205:810/arcgis_js_api/library/3.9/3.9/js/dojo/dijit/themes/tundra/tundra.css"/> <link rel="stylesheet" type="text/css" href="http://192.168.1.205:810/arcgis_js_api/library/3.9/3.9/js/esri/css/esri.css" /> <script type="text/javascript" src="http://192.168.1.205:810/arcgis_js_api/library/3.9/3.9/init.js"></script> <script type="text/javascript" src="dojo/jsapi_vsdoc10_v38.js"></script> <script type="text/javascript"> dojo.require("esri.map"); dojo.addOnLoad(function () { var MyMap = new esri.Map("MyMapDiv"); var myTiledMapServiceLayer = new esri.layers.ArcGISTiledMapServiceLayer("http://XXX/ArcGIS/rest/services/20130610_1454/MapServer"); var point = new esri.geometry.Point(118.0605760000, 36.8424320000, MyMap.spatialReference); //地图首次加载显示的位置和放大级别 MyMap.centerAndZoom(point, 8); MyMap.addLayer(myTiledMapServiceLayer); //创建图层 var graphicLayer = new esri.layers.GraphicsLayer(); //把图层添加到地图上 MyMap.addLayer(graphicLayer); //设置标注的经纬度 //方法一 var pt = new esri.geometry.Point(118.0605760000, 36.8424320000, MyMap.spatialReference); //方法二 // var pt = new esri.geometry.geographicToWebMercator(new esri.geometry.Point({ // "x": 118.0605760000, // "y": 36.8424320000, // "spatialReference": { "wkid": 102113 } // })); //设置标注显示的图标 //var sms = new esri.symbol.SimpleMarkerSymbol(); var sms = new esri.symbol.PictureMarkerSymbol("images/red.png", 25, 25); //要在模版中显示的参数 var attr = { "address": "山东省淄博市张店区" }; //创建模版 var infoTemplate = new esri.InfoTemplate("标题", "地址:${address}"); //创建图像 var graphic = new esri.Graphic(pt, sms, attr, infoTemplate); //把图像添加到刚才创建的图层上 graphicLayer.add(graphic); } ); </script> </head> <body> <div id="MyMapDiv" style=" width:600px; height:500px; border:1px solid #000" class="MapClass"></div> </body> </html>
时间: 2024-10-01 16:34:33