0

I am attempting to add a marker and then center on it from one action (right click) with gmaps.js in HTML. I have it working so when i right click it will add the new marker however i am unable to find a way to add the marker and center on the new marker at the same time. see below:

    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"
        }
    });
}
djsnakz
  • 468
  • 2
  • 6
  • 15
  • possible duplicate of [Google map V3 Set Center to specific Marker](http://stackoverflow.com/questions/6150409/google-map-v3-set-center-to-specific-marker) – SharpEdge May 24 '15 at 09:30

1 Answers1

0

You have to call

map.setCenter();

passing the point you want to center

map.setCenter(marker.getPosition());

Duplicate of: Google map V3 Set Center to specific Marker

Community
  • 1
  • 1
SharpEdge
  • 1,782
  • 1
  • 10
  • 20