码迷,mamicode.com
首页 > 其他好文 > 详细

腾讯地图标记点击事件

时间:2014-09-26 00:45:18      阅读:279      评论:0      收藏:0      [点我收藏+]

标签:腾讯地图   标记   点击事件   

<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>腾讯地图</title>
<script charset="utf-8" src="http://map.qq.com/api/js?v=2.exp&key=AMZBZ-NBWAR-SCKWS-WSFQU-TZ4R6-YWBEV"></script>
<script>
	var init = function() {
		var map_center = new qq.maps.LatLng(39.90927537429095,116.39838695526123);
		var map = new qq.maps.Map(document.getElementById("container"), {
			center : map_center,
			zoom : 14,
			panControl : true,
			zoomControl : true,
			zoomControlOptions : {
				style : qq.maps.ZoomControlStyle.SMALL
			}
		});

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

		var infoWin = new qq.maps.InfoWindow( {
			map : map
		});

		qq.maps.event.addListener(
				marker,
				‘click‘,
				function(evt) {
					infoWin.open();
					infoWin.setContent(‘<div style="text-align:center;white-space:nowrap;margin:10px;">这里是天安门</div>‘);
					infoWin.setPosition(evt.latLng);
		        });
        
	 }
</script>
	</head>
	<body onload="init()">
		<div style="width: 603px; height: 300px; padding-top: 80px; padding-left: 80px;" id="container"></div>
	</body>
</html>


效果如图:

bubuko.com,布布扣

由于腾讯地图接口变更,这是之前的写法,现在的qq.maps 都改为了soso.maps

具体参考:http://api.map.soso.com/doc/example.html?sample-overlay-marker-click#5map#5map


                  作者:itmyhome

 转载请注明出处:http://blog.csdn.net/itmyhome1990/article/details/39551131






腾讯地图标记点击事件

标签:腾讯地图   标记   点击事件   

原文地址:http://blog.csdn.net/itmyhome1990/article/details/39551131

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!