腾讯地图标记点击事件

<!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>


效果如图:

由于腾讯地图接口变更,这是之前的写法,现在的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






posted on 2014-09-25 22:44  itmyhome  阅读(3189)  评论(0编辑  收藏  举报

导航