Gmap4 guy
Gmap4 guy

Reputation: 331

Can my code get the Google map API version number?

I am not using the v parm when I load the Google map API. Therefore I always get the "release" version of the API.

My app has an "About" feature and I would like to display the API version number.

Is there a way for me to get that value or would this be an enhancement request?

Upvotes: 4

Views: 2218

Answers (2)

Dr.Molle
Dr.Molle

Reputation: 117334

simply use: google.maps.version

http://jsfiddle.net/doktormolle/anN4U/

Upvotes: 11

geocodezip
geocodezip

Reputation: 161354

There was a way to get it from the filename of the script that loaded:

//*************************************************************
// API version from post on Google Maps API group by bratliff
var file,loop;
var tags=document.getElementsByTagName("SCRIPT");
// alert("tags="+tags.length);

for (loop=0;tags[loop];loop++)
{
       if (file=tags[loop].src.match(/http:\/\/[^\&\?]+\.google\.[^\&\?]+\/([0-9]+)\/[^\&\?]+\/main\.js/)) {
          //alert(file[1]);
          document.getElementById("apiv").innerHTML = "API v2."+file[1];
       }
}
//*************************************************************

You should be able to do the something similar for API v3.

Upvotes: 0

Related Questions