根据下面的示例,我已经成功地使用GMaps.js向地图添加了快捷菜单
map.setContextMenu({
control: 'map',
options: [{
title: 'Add marker',
name: 'add_marker',
action: function(e) {
this.addMarker({
lat: e.latLng.lat(),
lng: e.latLng.lng(),
title: 'New marker'
});
}
}, {
title: 'Center here',
name: 'center_here',
action: function(e) {
this.setCenter(e.latLng.lat(), e.latLng.lng());
}
}]
});但是,我似乎不能向标记添加上下文菜单。
有没有人能告诉我怎么做?
谢谢
发布于 2015-09-17 13:01:39
这段代码非常适合我,如果你看不到contextMenu,也许你应该试试右击它会出现菜单!!
map.setContextMenu({
control: 'map',
options: [{
title: 'Add marker',
name: 'add_marker',
action: function(e){
this.addMarker({
lat: e.latLng.lat(),
lng: e.latLng.lng(),
animation: google.maps.Animation.DROP,
draggable:true,
title: 'New Marker'
});
this.hideContextMenu();
}
}, {
title: 'Center here',
name: 'center_here',
action: function(e){
this.setCenter(e.latLng.lat(), e.latLng.lng());
}
}]
});
map.setContextMenu({
control: 'marker',
options: [{
title: 'Center here',
name: 'center_here',
action: function(e){
this.setCenter(e.latLng.lat(), e.latLng.lng());
}
}]
});

发布于 2012-12-14 19:50:35
你指的是这里演示的infoWindow吗?http://hpneo.github.com/gmaps/examples/markers.html
如果您查看该页面的源代码,您会发现您只需要添加
infoWindow: {
content: '<p>HTML Content</p>'
}到你的addMarker位,即。在标题下面。真的很简单!:)
https://stackoverflow.com/questions/13847637
复制相似问题