Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

map.addOverlay in Google API v3

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)

like image 308
Jim Avatar asked Jun 06 '12 13:06

Jim


People also ask

Is Google Maps API still free?

Note that the Maps Embed API, Maps SDK for Android, and Maps SDK for iOS currently have no usage limits and are at no charge (usage of the API or SDKs is not applied against your $200 monthly credit).

How do I set Google Maps API?

Go to the Google Maps Platform > Credentials page. On the Credentials page, click Create credentials > API key. The API key created dialog displays your newly created API key. Click Close.


1 Answers

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

like image 101
Suvi Vignarajah Avatar answered Sep 30 '22 17:09

Suvi Vignarajah