1.如何初始化地图
webViewMap={}
CBSCache2.version = 1;
CBSCache2.id = CBSCache2.name;
CBSCache2.base64 = false;
webViewMap.map = new XiaoFu.Map("#cbscontent", { bgColor: "white" });
webViewMap.baseLayer = new XiaoFu.XiaoFuCacheLayer(CBSCache2);
webViewMap.map.addLayer(webViewMap.baseLayer);
2.添加marker层
var markerLayer = new XiaoFu.MarkerLayers("marker");
webViewMap.map.addLayer(markerLayer);
3.添加多个marker
for(var i=0;i<count;i++){
var coordinates = data.message.recordSets[0].records[i].geometry.coordinates;
var x=coordinates[0];
var y=coordinates[1];
var demo = $("<img/>")
.attr("src", "http://images.cnblogs.com/marker.png")
.css("width", 30)
.css("height", 30)
.css("position", "absolute")
.css("cursor", "pointer")
.css("border", "0px solid white");
var markerId = 'marker'+i;
var marker = new XiaoFu.Marker({id:markerId,x:x,y:y});
marker.data = demo;
markerLayer.addChild(marker);
}
4.添加infowindow
infoWindow =new XiaoFu.InfoWindow();
infoWindow.strHtml="testinfowindow";
infoWindow.x = 14254888.263400003;
infoWindow.y = 5161875.567100003;
webViewMap.map.addLayer(infoWindow);
infoWindow.show();
5.添加control
control = new XiaoFu.Navigation();
webViewMap.map.addControl(control);
control.showNavBar();
6.地图的平移
var point = new XiaoFu.GeoPoint(x,y);
webViewMap.map.panTo(point);