~~~
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>传递事件参数</title>
</head>
<body>
<div id="container"></div>
<p id="fixed"></p>
<iframe id="geoPage" width="100%" height="30%" frameborder="0" scrolling="no" style="display: none;" src="https://apis.map.qq.com/tools/geolocation?key=OB4BZ-D4W3U-B7VVO-4PJWW-6TKDJ-WPB77&referer=myapp&effect=circle"></iframe>
<script type="text/JavaScript">
window.addEventListener('message', function(event) {
// 接收位置信息
var loc = event.data;
init(loc.lat,loc.lng);
}, false);
</script>
<script charset="utf-8" src="https://map.qq.com/api/js?v=2.exp"></script>
<script>
function init(a,b) {
var map = new qq.maps.Map(document.getElementById("container"), {
center: new qq.maps.LatLng(a,b),
zoom: 16
});
//绑定单击事件添加参数
qq.maps.event.addListener(map, 'click', function(event) {
var lat= event.latLng.getLat();
var lng= event.latLng.getLng();
console.info(event);
document.getElementById("fixed").innerHTML=lat+","+lng;
});
}
</script>
</body>
</html>
~~~