gmap.js 添加标记和中心
gmap.js add marker and center
我正在尝试添加一个标记,然后在 HTML 中使用 gmaps.js 通过一次操作(右键单击)将其置于中心。我让它工作所以当我右键单击它会添加新标记但是我无法找到一种方法来添加标记并同时在新标记上居中。见下文:
map.addMarker({
lat: -38.059648,
lng: 144.33451,
title: "title",
icon: 'blah',
infoWindow: {
content:'blah'
},
rightclick: function(e){
map.addMarker({
lat: -31.958337,
lng: 115.821954,
title: "title",
icon: 'icon',
infoWindow: {
content:"blah"
}
});
}
你得打电话
map.setCenter();
通过你想要居中的点
map.setCenter(marker.getPosition());
副本:Google map V3 Set Center to specific Marker
我正在尝试添加一个标记,然后在 HTML 中使用 gmaps.js 通过一次操作(右键单击)将其置于中心。我让它工作所以当我右键单击它会添加新标记但是我无法找到一种方法来添加标记并同时在新标记上居中。见下文:
map.addMarker({
lat: -38.059648,
lng: 144.33451,
title: "title",
icon: 'blah',
infoWindow: {
content:'blah'
},
rightclick: function(e){
map.addMarker({
lat: -31.958337,
lng: 115.821954,
title: "title",
icon: 'icon',
infoWindow: {
content:"blah"
}
});
}
你得打电话
map.setCenter();
通过你想要居中的点
map.setCenter(marker.getPosition());
副本:Google map V3 Set Center to specific Marker