码迷,mamicode.com
首页 > 其他好文 > 详细

在地图上添加标注

时间:2014-09-28 17:37:23      阅读:277      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   io   ar   java   sp   div   

<!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>

 

bubuko.com,布布扣

在地图上添加标注

标签:style   blog   http   color   io   ar   java   sp   div   

原文地址:http://www.cnblogs.com/liuswi/p/3998283.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!