Google Maps API - undefined ROADMAP Property?

I implement two different types of google maps on my site.

  • The first simply shows predefined locations with markers using MapTypeID:

    mapTypeId: google.maps.MapTypeId.ROADMAP

  • The second allows the user to interact by dragging / dropping markers on the map, etc.

I call my API like this:

<script src="http://maps.google.com/maps?file=api&v=2.x&sensor=false&key=ABQIAAAAfK8z5AsiUZwKZF5CkZMF6BTAb5FWVJrlydeWm3IWDEdBI1HaUhTpyn3_qR2q3IPbPnQKou9lkKVqIA" type="text/javascript"></script> 

When starting my first map, I get this error:

 Uncaught TypeError: Cannot read property 'ROADMAP' of undefined 

If I load the Google Maps API in another way:

 <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> 

The error from the first map disappears, but now I get this error when starting the second map:

 Uncaught ReferenceError: GOverlay is not defined Uncaught ReferenceError: GControl is not defined Uncaught ReferenceError: GControl is not defined Uncaught ReferenceError: GCopyright is not defined 

I think the problem is with one map requiring an older version of google maps API. Can I download two separate Google Maps APIs?

thanks

+4
source share
3 answers

google.maps.MapTypeId.ROADMAP is Google Maps v3, but everything else you do is thing v2. Instead, try google.maps.MapType.G_NORMAL_MAP . (Then think about upgrading everything to v3.)

+2
source

If you are using Google Maps v3

Javascript includes google maps that have changed:

Instead: http://maps.google.com/maps/api/js?sensor=false

should be: https://maps.googleapis.com/maps/api/js?sensor=false

please follow this link https://developers.google.com/maps/documentation/webservices/

+2
source

Instead of this:

mapTypeId: google.maps.MapTypeId.ROADMAP

use this:

mapTypeId: 'roadmap'

0
source

All Articles