<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Hello World</title> <link rel="stylesheet" href="http://jsapi.thinkgis.cn/esri/css/esri.css"> <script src="http://jsapi.thinkgis.cn/init.js"></script> <script> require(["esri/map", "esri/layers/ArcGISTiledMapServiceLayer", "dojo/on", "esri/geometry/Point", "dojo/domReady!"], function (Map, ArcGISTiledMapServiceLayer, on, Point) { var map = new Map("mapDiv", { //center: [106.544827, 29.566127] zoom: 8 }); //利用url创建一个动态地图服务对象 var layer = new ArcGISTiledMapServiceLayer("http://183.64.63.98:6080/arcgis/rest/services/bkMap1/MapServer"); //将地图服务对象添加到地图容器中 map.addLayer(layer); //当第一个图层加载完成时候触发 map.on("load", function myfunction() { var p = new Point({ "x": 106.544688, "y": 29.566080, //中心点坐标为重庆市市政府的坐标 "spatialReference": map.spatialReference //设置空间参考为第一个图层的空间参考 }); map.centerAt(p); }); }) </script> </head> <body class="tundra"> <div id="mapDiv" style="width: 900px; height: 600px; border: 1px solid #000;"></div> </body> </html>
时间: 2024-10-11 12:39:38