• john twigg

    (@john-twigg)


    I have a google map, with a contact box covering the left hand side of the map. I am looking for code I can add to move the center of the map to the right.

    I have used Creative Google Maps App, which has provision to customise the style, and I tried the code listed below, but this did not work (not sure if this is complete code?)

    Any suggestions as to how I could offset this map?

    Thanks for taking an interest!

    ___

    var center; // a latLng
    var offsetX = 0.75; // move center one quarter map width right
    var offsetY = 0.5; // center

    var span = map.getBounds().toSpan(); // a latLng – # of deg map spans

    var newCenter = {
    lat: center.lat() + span.lat()*offsetY,
    lng: center.lng() + span.lng()*offsetX
    };

    map.setCenter(newCenter);

    ___

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    It appears center is not assigned a value. It can be gotten from the map object. You need something like center = map.getCenter(); The map object’s getCenter method is something I made up as a quick example. Use the actual method or property.

    This isn’t a WP issue though, it’s a Google maps coding issue. You’ll get people much more knowledgeable about maps coding than the folks here if you ask in the Google maps support forum.

Viewing 1 replies (of 1 total)
  • The topic ‘Offset Center of Google Map’ is closed to new replies.