使用百度地图小记

var map = new BMap.Map("allmap"); // 创建Map实例
map.centerAndZoom(new BMap.Point(x, y), h); // 初始化地图,设置中心点坐标和地图级别

//添加地图类型控件
var top_left = new BMap.MapTypeControl({
mapTypes: [
BMAP_NORMAL_MAP,
BMAP_HYBRID_MAP,
BMAP_SATELLITE_MAP
], anchor: BMAP_ANCHOR_TOP_LEFT
});

//添加地图样式

var myStyleJson = [
{
"featureType": "subway",
"elementType": "all",
"stylers": {
"visibility": "off"
}
}];
map.setMapStyle({ styleJson: myStyleJson });
// map.setMapStyle({
// styleJson: json
// });
map.setMapType(BMAP_HYBRID_MAP);
map.enableContinuousZoom();
map.addControl(top_left);
geo(new BMap.Point(x, y), map);
//map.setMapStyleV2({ styleJson: custom_map_config });
//map.setCurrentCity("北京"); // 设置地图显示的城市 此项是必须设置的
map.enableScrollWheelZoom(true); //开启鼠标滚轮缩放

posted @ 2019-12-02 10:20  绯颜旧雨  阅读(389)  评论(0编辑  收藏  举报