查看代码效果
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>搜索地图中公园的地址</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
<script type="text/javascript"
src="http://www.forbst.com/MainOutLine.html></script>
</head>
<body>
<div id="div_map" style="width: 100%; height: 100%; float: left;"></div>
<script type="text/javascript">
//var xxx=1111;
var map = null;
map = new STMapObj("div_map");
map.locateMap(new STMapPoint(116.4035, 39.915), 8);
map.setZoomCompVisible(true);
map.setScaleCompVisible(true);
//示例部分公园地址
var str2 = '{"gy": [{"gy":"北海公园,116.35577813720701,39.939748320120394"},{"gy":"遗址公园,116.28230706787109,40.02445665159343"},{"gy":"天坛公园,116.3880504760742,39.90604627678642"},{"gy":"世界公园,116.30153314208982,39.8254101109429"}]}';
test();
function test() {
var obj = eval('(' + str2 + ')');
var len = obj.gy.length;
for ( var i = 0; i < len; i++) {
var gongyuan = obj.gy[i].gy;
var str = new Array();
str = gongyuan.split(",");
var poly = new STMapMarker();
poly.id = "testline6" + i; //【必选】对象 id
poly.point = new STMapPoint(str[1], str[2]); //【必选】经纬度坐标 STMapPoint 类型
poly.img = "../img/carAPI.png"; //【必选】对象的图片地址 url
poly.label = ""; //【可选】鼠标提示
poly.size = "" //【可选】图片长宽 参数为 STMapSize 类型,默认为图片本身尺寸
poly.anchor = "BC" // 【可选】定位锚点,BC (下边中心点)BL (左下角)BR (右下角)TL (左上角)TC (上边中心点)TR (右上角)ML (左边中心点)MR (右边中心点)CENTER (图片中心点)
poly.infowin = false; //【可选】是否点击显示信息窗口,默认为 true。
map.addOverlay(poly);
}
}
</script>
<div style="display: none">
<script type="text/javascript">
var cnzz_protocol = (("https:" == document.location.protocol) ? " https://" : " http://");
document.write(unescape("%3Cspan id='cnzz_stat_icon_1000501913'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "s11.cnzz.com/z_stat.php%3Fid%3D1000501913' type='text/javascript'%3E%3C/script%3E"));
</script>
</div>
</body>
</html>查看代码效果