SOSO地圖JS畫出標(biāo)注和中心點(diǎn)以html形式運(yùn)行
更新時間:2013年08月09日 17:29:36 作者:
SOSO地圖想必大家都知道吧,本文將為大家詳細(xì)介紹下使用JS畫出標(biāo)注和中心點(diǎn),直接貼出代碼,感興趣的朋友可以參考下
直接貼出代碼,這個可以在本地創(chuàng)建一個html文件直接運(yùn)行:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Map</title>
<script charset="utf-8" src="http://map.soso.com/api/v2/main.js"></script>
<script>
function init() {
var center = new soso.maps.LatLng(31.15953,121.516035);
var map = new soso.maps.Map(
document.getElementById("container"),
{
center: center,//顯示地圖的中心位置
zoom: 15//顯示地圖的縮放級別
}
);
//地圖第一個mark的坐標(biāo)
var position1 = new soso.maps.LatLng(31.15751,121.514061);
var marker = new soso.maps.Marker({
position: position1,
map: map
});
//地圖第二個mark的坐標(biāo)
var position2 = new soso.maps.LatLng(31.160705,121.524017);
var marker = new soso.maps.Marker({
position: position2,
map: map
});
}
function loadScript() {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "http://map.soso.com/api/v2/main.js?callback=init";
document.body.appendChild(script);
}
window.onload = loadScript;
</script>
</head>
<body onload="init()">
<div id="container" style="width:1000px; height:800px"></div>
</body>
</html>
復(fù)制代碼 代碼如下:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Map</title>
<script charset="utf-8" src="http://map.soso.com/api/v2/main.js"></script>
<script>
function init() {
var center = new soso.maps.LatLng(31.15953,121.516035);
var map = new soso.maps.Map(
document.getElementById("container"),
{
center: center,//顯示地圖的中心位置
zoom: 15//顯示地圖的縮放級別
}
);
//地圖第一個mark的坐標(biāo)
var position1 = new soso.maps.LatLng(31.15751,121.514061);
var marker = new soso.maps.Marker({
position: position1,
map: map
});
//地圖第二個mark的坐標(biāo)
var position2 = new soso.maps.LatLng(31.160705,121.524017);
var marker = new soso.maps.Marker({
position: position2,
map: map
});
}
function loadScript() {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "http://map.soso.com/api/v2/main.js?callback=init";
document.body.appendChild(script);
}
window.onload = loadScript;
</script>
</head>
<body onload="init()">
<div id="container" style="width:1000px; height:800px"></div>
</body>
</html>
相關(guān)文章
JS實現(xiàn)的文字間歇循環(huán)滾動效果完整示例
這篇文章主要介紹了JS實現(xiàn)的文字間歇循環(huán)滾動效果,涉及javascript結(jié)合時間函數(shù)定時觸發(fā)實現(xiàn)頁面元素動態(tài)操作相關(guān)技巧,需要的朋友可以參考下2018-02-02JS中類的靜態(tài)方法,靜態(tài)變量,實例方法,實例變量區(qū)別與用法實例分析
這篇文章主要介紹了JS中類的靜態(tài)方法,靜態(tài)變量,實例方法,實例變量區(qū)別與用法,結(jié)合實例形式詳細(xì)分析了JS中類的靜態(tài)方法,靜態(tài)變量,實例方法,實例變量相關(guān)功能、使用方法及操作注意事項,需要的朋友可以參考下2020-03-03關(guān)于動態(tài)執(zhí)行代碼(js的Eval)實例詳解
下面小編就為大家?guī)硪黄P(guān)于動態(tài)執(zhí)行代碼(js的Eval)實例詳解。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-08-08ionic開發(fā)中點(diǎn)擊input時鍵盤自動彈出
ionic開發(fā)移動端界面時,在輸入用戶名和密碼的時候,輸入法不要擋住我的輸入框,并且輸入框往上滾動的時候,頂部標(biāo)題不要上移,下面給大家分享實現(xiàn)代碼,一起看看吧2016-12-12ES6知識點(diǎn)整理之函數(shù)對象參數(shù)默認(rèn)值及其解構(gòu)應(yīng)用示例
這篇文章主要介紹了ES6知識點(diǎn)整理之函數(shù)對象參數(shù)默認(rèn)值及其解構(gòu)應(yīng)用,結(jié)合實例形式分析了ES6函數(shù)對象參數(shù)相關(guān)使用技巧,需要的朋友可以參考下2019-04-04Immutable 在 JavaScript 中的應(yīng)用
在 JavaScript 中,對象是引用類型的數(shù)據(jù),其優(yōu)點(diǎn)在于頻繁的修改對象時都是在原對象的基礎(chǔ)上修改,并不需要重新創(chuàng)建,這樣可以有效的利用內(nèi)存,不會造成內(nèi)存空間的浪費(fèi),對象的這種特性可以稱之為 Mutable,中文的字面意思是「可變」2016-05-05