$(function() {
// 声明变量map、layer、url
var map, layer, LayerNames = {},
url = "http://114.251.53.254:8090/iserver/services/map-TZ_MapWorkSpace/rest/maps/TZMap";
// 创建地图控件
map = new SuperMap.Map("xmap", {
controls : [ new SuperMap.Control.ScaleLine(),
new SuperMap.Control.OverviewMap(),
new SuperMap.Control.Zoom(),
new SuperMap.Control.Navigation({
dragPanOptions : {
enableKinetic : true
}
}) ],
allOverlays : false
});
// map.addControl(new SuperMap.Control.ZoomBox());
LayerName = "通州矢量地图";
// 增加轨迹图
var vectorLayer = new SuperMap.Layer.Vector();
var start = new SuperMap.Geometry.Point(116.708, 39.840);
var senter = new SuperMap.Geometry.Point(116.708, 39.740);
var end = new SuperMap.Geometry.Point(116.808, 39.840);
var line = new SuperMap.Geometry.LineString([ start, senter, end ]);
var lineVector = new SuperMap.Feature.Vector(line);
vectorLayer.addFeatures(lineVector);
// 标记图层上添加标记
var size = new SuperMap.Size(21, 25);
var offset = new SuperMap.Pixel(-(size.w / 2), -size.h);
var icon = new SuperMap.Icon('../theme/images/marker.png', size, offset);
var markers = new SuperMap.Layer.Markers("Markers");
markers.addMarker(new SuperMap.Marker(new SuperMap.LonLat(116.708, 39.840),
icon));
// 创建分块动态REST图层,该图层显示iserver 7C 服务发布的地图,
// 其中“world”为图层名称,url图层的服务地址,{transparent: true}设置到url的可选参数
layer = new SuperMap.Layer.TiledDynamicRESTLayer(LayerName, url, null, {
maxResolution : "auto"
});
layer.events.on({
"layerInitialized" : addLayer
});
function addLayer() {
// 将Layer图层加载到Map对象上
map.addLayer(layer);
map.addLayer(markers);
map.addLayer(vectorLayer);
// 出图,map.setCenter函数显示地图
map.setCenter(new SuperMap.LonLat(116.708, 39.840), 11, false, false);
}
});