radioman / greatmaps

GMap.NET - Great Maps for Windows Forms & Presentation
912 stars 408 forks source link

Google server connection #106

Open pablomacri1 opened 5 years ago

pablomacri1 commented 5 years ago

we've been using this great project in our app for a long time, but since today all clients sttoped working with google maps connection. I've tried with the demo, and it also can't locate any adress (it returns "reason unknown"). today I also notticed an update in chrome and many google apps. Maybe they hava done an update to the tiles server? I would really apreciate if there is a way to keep using google maps as the provider.. thanks

LBoullosa commented 5 years ago

Hi, I found the main reason for me.

<GeocodeResponse><status>OVER_QUERY_LIMIT</status><error_message>You have exceeded your rate-limit for this API. We recommend registering for a key at the Google Developers Console: https://console.developers.google.com/apis/credentials?project=_</error_message></GeocodeResponse>

Try the exact reason for you padromacri1, for example using Wireshark.

So my second step was creating an api key for development. I updated my app to use GMapsNET 1.7.5 which supports apikey through ((GoogleMapProvider)gMap.MapProvider).ApiKey = apiKey;

But now i got the next message because request goes via http instead https. You can see it in this picture, imagen

I forgot the response content imagen

Is there any way to change the url? I tried referedUrl property but it doesn´t work.

Thanks in advance.

pablomacri1 commented 5 years ago

wow, I didn't try to capture the response. It seems that the "reason unknonw" is a generic and this error is not captured. The strange thing is that it fails every time (so it appears that the query limit is 0) Radioman, can you check on this please?

LBoullosa commented 5 years ago

I think google changed license terms for using googlemaps api. I don´t read a lot about the terms but now It looks like all requests need to have an api key. And in other part is securing the comunication with the API which is a good thing, i think.

For detailed info, https://cloud.google.com/maps-platform/user-guide/account-changes/

ghost commented 5 years ago

For most Google APIs you will need to change the URLs to HTTPS and you need to set the API Key. There is no nice way to change the URLs, but you can use this and call it during init:

public static void FixUrls()
{
    var maps = typeof(GoogleMapProviderBase);
    var urls = maps.GetFields(BindingFlags.Static | BindingFlags.GetField | BindingFlags.NonPublic)
        .Where(x => x.Name.Contains("UrlFormat") && x.FieldType == typeof(string));
    foreach (var url in urls)
    {
        var value = (string)url.GetValue(null);
        url.SetValue(null, value.Replace("http://", "https://"));
    }
}