map.addOverlay in Google API v3
Asked Answered
C

1

6

is this the correcty way to change the add Overlay to v3? In V3 addOverlay is deprecated...and replaced with setMap?

    if (setContainerVisible == 1) {
        mapElements[lMapElementIndex]['visible'] = 1;
        //map.addOverlay(marker); v2
        marker.setMap(marker); // v3 ??
    }

for more infos see the whole source http://pastebin.com/w1nm0W75 (line: 507)

Chive answered 6/6, 2012 at 13:38 Comment(0)
K
11

Not quite, there is actually a number of ways you can do it. The simplest, and what you're probably looking for is

marker.setMap(map);

You can also initialize the map it supposed to be bound to when initializing your marker variable in the markerOptions.

Take a look at this document, it describes the methods and approaches to add markers and other overlays in V3: https://developers.google.com/maps/documentation/javascript/overlays#AddingOverlays

Kisung answered 6/6, 2012 at 14:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.