Google Maps API V3 Infobox.js removed

It seems that the library is being moved to Github (it seems the infobox.js wasn’t moved yet), see the announcement on main page: https://code.google.com/p/google-maps-utility-library-v3/ But still, the problem with your code is that it’s not a good practise to reference code from code.google.com svn repository. It’s like referencing a code from Github, it can be … Read more

Google Maps API throws “Uncaught ReferenceError: google is not defined” only when using AJAX

The API can’t be loaded after the document has finished loading by default, you’ll need to load it asynchronous. modify the page with the map: <div id=”map_canvas” style=”height: 354px; width:713px;”></div> <script src=”https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js”></script> <script src=”https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&callback=initialize”></script> <script> var directionsDisplay, directionsService, map; function initialize() { var directionsService = new google.maps.DirectionsService(); directionsDisplay = new google.maps.DirectionsRenderer(); var chicago = new … Read more

Google Maps V3 – How to calculate the zoom level for a given bounds

Thanks to Giles Gardam for his answer, but it addresses only longitude and not latitude. A complete solution should calculate the zoom level needed for latitude and the zoom level needed for longitude, and then take the smaller (further out) of the two. Here is a function that uses both latitude and longitude: function getBoundsZoomLevel(bounds, … Read more

Google Map API – Removing Markers

You need to keep an array of the google.maps.Marker objects to hide (or remove or run other operations on them). In the global scope: var gmarkers = []; Then push the markers on that array as you create them: var marker = new google.maps.Marker({ position: new google.maps.LatLng(locations[i].latitude, locations[i].longitude), title: locations[i].title, icon: icon, map:map }); // … Read more

How to Display Multiple Google Maps per page with API V3

Here is how I have been able to generate multiple maps on the same page using Google Map API V3. Kindly note that this is an off the cuff code that addresses the issue above. The HTML bit <div id=”map_canvas” style=”width:700px; height:500px; margin-left:80px;”></div> <div id=”map_canvas2″ style=”width:700px; height:500px; margin-left:80px;”></div> Javascript for map initialization <script type=”text/javascript”> var … Read more

Google maps Places API V3 autocomplete – select first option on enter

Here is a solution that does not make a geocoding request that may return an incorrect result: http://jsfiddle.net/amirnissim/2D6HW/ It simulates a down-arrow keypress whenever the user hits return inside the autocomplete field. The ↓ event is triggered before the return event so it simulates the user selecting the first suggestion using the keyboard. Here is … Read more

How to make cross-domain AJAX calls to Google Maps API?

I can see no advantage in using the Server-side Geocoding Web Service when Google Maps provides a full featured Client-side Geocoding API for JavaScript. First of all, this automatically solves your same-origin problem, and in addition the request limits would be calculated per client IP address instead of of per server IP address, which can … Read more