Good trick ! I didn't think to try the existence of a class only
present in one or the other version,
Thanks for the complete reply,

Mike

On Nov 30, 11:29 pm, Mike Williams <[email protected]> wrote:
> In your case, I'd recommend testing for the existence of a class that
> exists in v2 but not v3, and is unlikely to ever exist in v3. Possible
> targets are Maps2 and XmlHttp.
>
>   if(google.maps.Maps2){
>     alert("....")
>   }
> or
>   if(GMaps2){
>     alert("....")
>   }
>
> In v2 there's a G_API_VERSION, but that only tells you the sub version
> (e.g. it currently returns "184a" not "2.184a") but it's possible that
> v3 might get a G_API_VERSION once it comes out of Labs and gets version
> management. So that might not be conclusive.
>
> At present, the only way to know what version of v3 you're running is to
> look at the src name of the js file:
>       var scripts = document.getElementsByTagName("SCRIPT")
>       for (var n = 0 ; n < scripts.length ; n++ ){
>         var a=scripts[n].src;
>         if (a.indexOf("main.js")>-1) {
>            ...
>         }
>       }
> At present the src is
>  http://maps.gstatic.com/intl/en_gb/mapfiles/api-3/22a/main.js
> for v3 and
>  http://maps.gstatic.com/intl/en_ALL/mapfiles/184a/maps2.api/main.js
> for v2.
>
> The problem with that is that Google do change their file naming
> conventions from time to time, so you need to have some quite clever
> code where I've put the "..." to be certain of coping with such changes.
> And there's always the possibility (it's never happened yet) that Google
> might change the name from "main.js".
>
> --
> Mike Williams
> Gentleman of Leisure

--

You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.


Reply via email to