欢迎来到代码驿站!

JavaScript代码

当前位置:首页 > 网页前端 > JavaScript代码

SOSO地图JS画出标注和中心点以html形式运行

时间:2021-07-04 09:26:28|栏目:JavaScript代码|点击:
直接贴出代码,这个可以在本地创建一个html文件直接运行:
复制代码 代码如下:

<!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的坐标
var position1 = new soso.maps.LatLng(31.15751,121.514061);

var marker = new soso.maps.Marker({
position: position1,
map: map
});

//地图第二个mark的坐标
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>

上一篇:5 cool javascript apps

栏    目:JavaScript代码

下一篇:JavaScript之Getters和Setters 平台支持等详细介绍

本文标题:SOSO地图JS画出标注和中心点以html形式运行

本文地址:http://www.codeinn.net/misctech/152522.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有