MapProvider.TryCorretVersion and Exclusive Offline usage

Topics: General
Feb 6, 2013 at 5:21 PM
I can't find any post where this is addressed so...

I am using gmap exclusively offline. I found that for Bing and Google there doesn't seem to be a way to force the MapProvider to NOT look for the dns name.

OnInitialize() will try to connect to the URL unless init == true or TryCorrectVersion == false.

I have made TryCorrectVersion Public Static so that when I load my map, I simply turn TryCorrectVersion = false and the URL is not attempted.

I wouldn't be surprised if there is a better, legitimate way to do this that I'm unaware of.


Feb 6, 2013 at 5:34 PM
just set TryCorrectVersion before map.MapProvider = xxx
Feb 6, 2013 at 5:37 PM
Right, that's what I do, however, I had to hack the source to promote TryCorrectVersion from public to public static.

I did this for the 2 classes I use: BingHybridMapProvider and GoogleHybridMapProvider.
Feb 6, 2013 at 6:00 PM
no need to make them static
Feb 6, 2013 at 6:42 PM
When I load the xml file for a cached map, it has the provider. I use:

GMapProvider provider = GMapProvider.TryGetProvider(xmlParams.ProviderGUID);

GMapProvider base class does not have TryCorrectVersion.

So in order to set that public member value, I have to check the underlying type of GMapProvider, then set the value. THEN I can assign it to map.MapProvider.

Ideally, TryCorrectVersion would be a static member in GMapProvider. But since I don't see that it is used anywhere but in Bing and Google, I don't think that's better. Having it only in Bing and Google means that you have to IF (or Switch) the provider. Having it static means it's set and done once.

Yes, you are right, I can do what you said. However I believe this method is cleaner.

Anyway, thanks for your help.
Feb 6, 2013 at 6:44 PM
What I also noticed is the map.Manager.Mode = AccessMode.CacheOnly should really turn off all attempts to contact the internet. Cache Only means (to me) "use the cache, only."

thanks again.
Feb 6, 2013 at 6:48 PM
GMapProviders.GoogleMap.TryCorrectVersion = false; // <==