var map;
require([
"esri/map",
"esri/layers/ArcGISTiledMapServiceLayer",
"esri/geometry/Extent",
"esri/geometry/Point",
"esri/symbols/PictureMarkerSymbol",
"esri/layers/GraphicsLayer",
"esri/graphic",
"esri/InfoTemplate",
"dojo/domReady!"],
function(Map, ArcGISTiledMapServiceLayer,Extent,Point,PictureMarkerSymbol,GraphicsLayer,graphic,InfoTemplate) {
//创建地图对象
map = new Map("map",{
center: [117.2298,39.0834],
zoom: 11,
//extent: new Extent({xmin:519388-5000,ymin:4326744-5000,xmax:519388+5000,ymax:4326744+5000,spatialReference:{wkid:4548}})
});
// var point = new Point(117.2298,39.0834);
//map.centerAndZoom(point, 8);//不起作用
//创建瓦片图层对象
var Layer = new ArcGISTiledMapServiceLayer("http://cache1.arcgisonline.cn/arcgis/rest/services/ChinaOnlineCommunity/MapServer");
map.addLayer(Layer);
//创建图层并完成标点
var graphicLayer = new GraphicsLayer();
map.addLayer(graphicLayer);
var symbol = new PictureMarkerSymbol("/img/location.png", 32, 32);
var attr = { "address": "天津xxxxxxxx" };
var infoTemplate = new InfoTemplate("位置信息", "地址:${address}");
var point = new Point(117.2298,39.0834);
var graphic = new graphic(point, symbol, attr, infoTemplate);
graphicLayer.add(graphic);
}
);
效果如下:

重要提示:下载arcgis_js_api后,务必要将init.js中的baseUrl改完自己系统的相对路径,有些版本也需要更改dojo.js中的baseUrl

这段代码展示了如何利用Esri的ArcGIS JavaScript API创建一个地图,并在地图上添加了一个图层和一个标记点。地图的中心点位于中国天津,使用了ArcGISTiledMapServiceLayer加载瓦片图层,并创建了一个带有信息模板的图形层来显示标记点的详细信息。
770

被折叠的 条评论
为什么被折叠?



