1 打開百度地圖生成器:
http://api.map.baidu.com/lbsapi/creatmap/
2 設置好了之后,點擊獲取代碼,將代碼粘貼到文件中保存為html文件
參考網址:https://jingyan.baidu.com/article/ce436649f1b5503772afd37a.html
https://jingyan.baidu.com/article/c45ad29cdc5d4f051753e2d2.html
3 有可能圖標消失,中文亂碼,解決如下(百度地圖生成器 缺失標注):
圖標消失是原icon圖片沒有了,手動把
- new BMap.Icon("http://app.baidu.com/map/images/us_mk_icon.png"
- /*修改為*/
- new BMap.Icon("http://map.baidu.com/image/us_mk_icon.png"
中文亂碼是因為生成的網頁代碼中,charset設置成gbk了,手動把
- <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
- /*修改為*/
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
自定義名字undefind是因為生成的代碼有個錯誤,手動把69行左右的代碼
- var label = new BMap.Label(json.titlea,{"offset":new BMap.Size(json.icon.lb-json.icon.x+10,-20)});
- /*修改為*/
- var label = new BMap.Label(json.title,{"offset":new BMap.Size(json.icon.lb-json.icon.x+10,-20)});
- /*注意沒titlea改成title*/
參考網址:http://blog.csdn.net/sinat_33157758/article/details/68500674
https://www.toolmao.com/baidumap-us-mk-icon
第二種:用地圖名片
http://api.map.baidu.com/mapCard/
