國(guó)外常用谷歌地圖,我們國(guó)內(nèi)有百度地圖,而且用起來(lái)也是蠻方便的,大家可以來(lái)試試。
- 原文參考:詳情
在百度地圖開放平臺(tái)(http://lbsyun.baidu.com/)登錄賬號(hào)新建應(yīng)用,應(yīng)用類型選擇瀏覽器端,建立完成后我們會(huì)得到應(yīng)用AK
。


css樣式代碼
#allmap {width: 100%;height: 100%;overflow: hidden;margin:0;font-family:"微軟雅黑";height: 350px;}
地圖顯示代碼
<script type="text/javascript" src="http://api.map.baidu.com/api?type=webgl&v=1.0&ak=你的ak"></script>
<div id="allmap"></div>
<script type="text/javascript">
// 百度地圖API功能
var map = new BMapGL.Map("allmap");
var point = new BMapGL.Point(坐標(biāo),坐標(biāo));
map.centerAndZoom(point, 15);//顯示層級(jí),具體可以參考下方坐標(biāo)拾取那里,層級(jí)越高地址越詳細(xì)
var marker = new BMapGL.Marker(point); // 創(chuàng)建標(biāo)注
map.addOverlay(marker); // 將標(biāo)注添加到地圖中
var opts = {
width : 200, // 信息窗口寬度
height: 100, // 信息窗口高度
title : "公司名" , // 信息窗口標(biāo)題
}
var infoWindow = new BMapGL.InfoWindow("詳細(xì)地址說(shuō)明", opts); // 創(chuàng)建信息窗口對(duì)象
map.openInfoWindow(infoWindow, point); //開啟信息窗口
//marker.addEventListener("click", function(){map.openInfoWindow(infoWindow, point);}); //點(diǎn)擊位置開啟信息窗口
</script>
關(guān)于坐標(biāo)如何獲取?
打開百度拾取坐標(biāo)網(wǎng)站(http://api.map.baidu.com/lbsapi/getpoint/index.html),直接搜索地址,然后點(diǎn)擊具體位置即可獲取坐標(biāo)!
