我的项目中需要在googlemap上标记某些地点,这个在地图上添加MarkerOptions就可以了,可是我找不到MarkerOptions如何添加点击事件,因为我要在用户点击标记点的时候弹出一个详细的布局来展示地点信息,请问要然后解决这个问题呢
marker.addEventListener('click',function(){........})
你能翻墙看这个:https://developers.google.com/maps/documentation/javascript/markers?hl=zh-cn
// The following example creates a marker in Stockholm, Sweden using a DROP
// animation. Clicking on the marker will toggle the animation between a BOUNCE
// animation and no animation.
var marker;
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 13,
center: {lat: 59.325, lng: 18.070}
});
marker = new google.maps.Marker({
map: map,
draggable: true,
animation: google.maps.Animation.DROP,
position: {lat: 59.327, lng: 18.067}
});
marker.addListener('click', toggleBounce);
}
function toggleBounce() {
if (marker.getAnimation() !== null) {
marker.setAnimation(null);
} else {
marker.setAnimation(google.maps.Animation.BOUNCE);
}
}
market添加监听事件,你说的信息框应该是一个callout