阅读:1566回复:0
百度地图API底色主题更换
百度地图api 也有自己写好的样式,数组中前三个不需要引入第三方库
其他的则需要引入 var style_map=['normal','light','dark','redalert','googlelite','grassgreen','midnight','pink','darkgreen','bluish','grayscale','hardedge']; //分别风格是:默认地图样式,清新蓝风格,黑夜风格,红色警戒风格,精简风格,自然绿风格,午夜蓝风格,浪漫粉风格,青春绿风格,清新蓝绿风格,高端灰风格,强边界风格 <script type="text/javascript" src="http://developer.baidu.com/map/custom/stylelist.js"></script> 一、通过样式ID调用个性化地图样式 map.setMapStyleV2({ styleId: '3d71dc5a4ce6222d3396801dee06622d' }); 二、通过样式JSON调用个性化地图样式 var style_map=[{ // 地图背景 "featureType": "land", "elementType": "all", "stylers": { "color": "#93c47dff", "lightness": -1 } }, { // 水路背景 "featureType": "water", "elementType": "all", "stylers": { "color": "#a2c4c9ff", "lightness": -1 } }, { // 绿地背景 "featureType": "green", "elementType": "all", "stylers": { "color": "#ffffccff", "lightness": -1 } },{ // 教育地区 "featureType": "education", "elementType": "all", "stylers": { "color": "#d5a6bdff", "lightness": -1 } } ] //将样式加载到地图中 map.setMapStyleV2({styleJson:eval("style_map")}); 然后地图样式就修改了 https://blog.csdn.net/cddcj/article/details/128946896 |
|