<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<title>事件模拟触发</title>
<link rel="stylesheet" href="https://a.amap.com/jsapi_demos/static/demo-center/css/demo-center.css" type="text/css">
<style>
html,body,#container{
height: 100%
}
</style>
</head>
<body>
<div id="container"></div>
<script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=您申请的key值"></script>
<script src="https://a.amap.com/jsapi_demos/static/demo-center/js/demoutils.js"></script>
<script type="text/javascript">
//初始化地图对象,加载地图
var map = new AMap.Map("container", {
resizeEnable: true,
zoom: 13
});
var clickHandler = function(e) {
log.success("您模拟触发了地图click事件!");
new AMap.InfoWindow({
content:'模拟事件触发',
}).open(map,e.lnglat)
};
//
map.on('click', clickHandler);
map.on('complete', function() {
setTimeout(function(){
// 模拟触发地图click事件
map.emit('click',{
lnglat : map.getCenter()
});
},2000)
})
</script>
</body>
</html>
订阅评论
0 评论