ThinkGeo.com    |     Documentation    |     Premium Support

Problem when GoogleMapsLayer draws

Hi Guys,



We have been using GoogleMapsLayer for some time now. We don’t have a license so we just use the free features. Recently we started getting the following error whenever the GoogleMapsLayer draws:



The remote server returned an error: (403) Forbidden.



We always get this error when the GoogleMapsLayers tries to draw.



Our current version of MapSuite is 7.0.0.234.



Can you help with this?



Thanks!



Steve


Hi Steven,



This is an urgent issue that we can image as the Google did some limitations on their static map server recently. It’s caused by the license limitation, please refer to this thread to resolve it: thinkgeo.com/forums/MapSuite…aspx 



Hope it helps.

Thanks,

Troy

Hi Troy, 



I have read the thread and I still cannot make it work. I activated the Static Maps API and obtained an API key and a client ID. If I set both the API key and Client ID I get the following: 



 Invalid length for a Base-64 char array or string. 



The information on Google’s site is very vague. I does not say anything about requiring a Client ID, but if I do not provide one, and just provide the API key, I get error 403.  



I must be missing something if everyone but me can get it working. Any ideas? 



Thanks, 



Steve

Hi Steven, 



Sorry for the delay. 

I guess you have updated the production version, one is our previous version which supports the Api Key and without the ClientID. And the other one is we have removed the Api Key and provide the ClientID and private key instead. 



For the version with ApiKey(simple access), we just need to activate the Static Maps API in the Google Console and then the map should can display when we use the Api key. 

But if we upgrade to the new version which needs us provide the clientID and the private key, To be honest, I also encountered an issue to display the GoogleMap with the client ID generated from the Google Console, I am not sure if I are missing something and we are still working on it. So, seems the version is still unstable and would you try to roll back and  

try the previous version temporary. 



Thanks for your patience. 

Regards, 

Troy

Troy, 
  
 Thanks for the explanation. I rolled back to v 7.0.0.185 (the next oldest production version I have) and set the APIKey on the GoogleMapsLayer and it works OK. Please advise when your team implements a permanent solution. 
  
 Thanks! 
  
 Steve

Steve, 
  
 Thanks for your patience and I will update here once we figure out a good solution. 
  
 Regards, 
 Troy

Hi Steven,



Thanks for the waiting.
Not pretty sure what your Google ClientID is, but I guess The reason I encounter the 403 error when using the clientID is because we are using the personal ClientID from Google Console rather that the enterprise ClientId and its secret key instead. One of our custom owns an enterprise ID and can get the correct images with our latest version. So, I think our current version have worked fine if there is an enterprise ClientID for Googlelayer.



Here is the thread: thinkgeo.com/forums/MapSuite…fault.aspx



Regards,
Troy

Hi Troy,



Thanks for your response. I don’t have an Enterprise ClientID. In the Google console I have a ‘Client ID for installed applications’. I also do not have a Private Key. I do have an API key. All I want to be able to do is access the free Google Maps services.



In earlier versions of MapSuite we could access the free Google Maps services without providing a key of any kind. Then, suddenly we could not, and kept getting error 403. You suggested I roll back to an earlier version, so I rolled back to 7.0.0.185. In this version we could access the maps by providing my API key in the constructor of the GoogleMaps layer. That worked fine.



With the latest version, just downloaded today, I can no longer provide the API key. It is not accepted in the constructor of the GoogleMapsLayer and not a property either. It seems the API key has been replaced by the PrivateKey and ClientID (but I think those are only supposed to be needed for paid access).



So now there is no longer a way for me to provide my API key. I can display the GoogleMapsLayer, but after a few redraws, error 403 appears again. This is getting a little confusing.



What is the correct way to access the free GoogleMaps services with the latest MapSuite API? Could you provide a code snippet?



Thanks!



Steve 


Hi Steven,



Okay, Yes, In the latest version of Map Suite, we don’t provide the Api key as API any more by following Google. Here are three options for us to access Google map and two of them have the limits which will caused 403 error:


// method 1: using the default without the Api key or clientId, limitation: 1 000 Static Maps requests per IP address per 24 hour period.
    GoogleMapsLayer googlelayer = new GoogleMapsLayer();
    // method 2: using Api key, limitation: 25 000 Static Maps requests per 24 hour period.
    googlelayer.CreatingRequest += new EventHandler(googlelayer_CreatingRequest);
    // method 3: using the request for business with ClientId, No limitation
    //googlelayer.ClientId = “xxx”;
    //googlelayer.PrivateKey = “xxx”;
 
static void googlelayer_CreatingRequest(object sender, CreatingRequestGoogleMapsLayerEventArgs e)
{
    e.RequestUri = new Uri(e.RequestUri.AbsoluteUri + “&key={API_KEY}”);
}

So, the method 2 with API key should be fit for you and the codes might not elegance but it is the only way for Api key currently.

BTW, to order to use the Api key, please follow the google guide to active the key in the google console(I remember you have done this).



Hope it helps.

Regards,

Troy

Troy,



Thanks, your solution works perfectly. In my business, results are more important than elegance. For anyone else strugging with this issue, here’s what it looks like in vb.net:


Private Sub CustomGoogleMapsLayer_CreatingRequest(sender As Object, e As ThinkGeo.MapSuite.Core.CreatingRequestGoogleMapsLayerEventArgs) Handles Me.CreatingRequest
   e.RequestUri = New Uri(e.RequestUri.AbsoluteUri + “&key=xxxxxxxxxxx-xxx_xxxxxxxxxxxxxx_xxxxxxxx”)
 
End Sub





Thanks again!



Steve

Hi Steven, 
  
 Great to hear it is sorted out, if you have any more question, please feel free to let us know. 
  
 Best Regards 
  
 Summer

I’m Facing the same issue using thinkgeo map suite 10.3.2. I have provided google maps api key using google maps layer creating request event but it still shows the Forbidden 403 error. The google maps api key is paid and serving the requests well in a simple html page. Please guide me

Hi M_Saeed_Chamman,

I find a topic about it, do you think it’s helpful?

Regards,

Ethan