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