Click Event to Center and Zoom Map?

Home Forums MapPress Support Click Event to Center and Zoom Map?

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #13000
    backbeat
    Participant

    I’d like to create a click event to center and zoom on a specific ZIP code (using lat/long). I can get the map to zoom to the existing center using setZoom(), but can’t get setCenter() to work.

    Is it possible? If so, how?

    Thanks.

    #13002
    Chris
    Keymaster

    Hi,

    You need to know the map name (you can set it in the shortcode or it’ll default to ‘mapp0’ for the first map).

    Then the code is:
    mapp0.setCenter(-32,22);

    Or you can get the google map object and call its functions directly:

    var gmap = mapp0.getMap();
    gmap.setCenter(new google.maps.LatLng(-32, 22));
    
    #13003
    backbeat
    Participant

    Thank you. That worked. I was making it harder than it needed to be…

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.