ThinkGeo.com    |     Documentation    |     Premium Support

Google Map display issues

Using MapSuite 9.0.0.180 for MVC. I have loaded multiple background maps into my project (Google/Bing/OpenStreetMap) and everything runs well on my local machine. Howerver, when I upload the project to the server the Google maps will not load and actually crashes the program. What could be causing this error. Below is the client side code.

@{
            Html.ThinkGeo().Map(Model)
                .MapUnit(GeographyUnit.Meter)
                .CustomOverlays(overlays =>
                {
                    overlays.GoogleOverlay("GoogleSatellite").GoogleMapType(GoogleMapType.Satellite).Name("Google - Satellite");
                    overlays.GoogleOverlay("GoogleRoad").GoogleMapType(GoogleMapType.Normal).Name("Google - Road");
                    overlays.GoogleOverlay("GoogleHybrid").GoogleMapType(GoogleMapType.Hybrid).Name("Google - Hybrid");
                    overlays.GoogleOverlay("GooglePhysical").GoogleMapType(GoogleMapType.Physical).Name("Google - Terrain");
                    overlays.BingMapsOverlay("BingAerial").MapType(BingMapsStyle.Aerial).Name("Bing - Aerial");
                    overlays.BingMapsOverlay("BingRoad").MapType(BingMapsStyle.Road).Name("Bing - Road");
                    overlays.BingMapsOverlay("BingHybrid").MapType(BingMapsStyle.Hybrid).Name("Bing - Hybrid");
                    overlays.OpenStreetMapOverlay("OpenStreetMaps").Name("OpenStreetMaps");
                })
                .OnClientClick("mapClick")
                .Render();
        }

Hi Chad,

we created one sample to reproduce your issue but failed. we have one google sample here: http://samples.thinkgeo.com/MvcEdition/HowDoISamples/BackgroundMaps/UseGoogleMap/1,BackgroundMaps

you can get the latest code from product center. If there is still meet this issue, please let us error message and call stack, we can help to figure out this.

I guess your issue maybe caused by Google Map ApiKey, currently, there are three ways to request the Google map images:

  1. Request without an API key: 1 000 Static Maps requests per IP address per 24 hour period and 50 Static Maps requests per IP address per minute
  2. Request with Api key: 25 000 Static Maps requests per 24 hour period.
  3. Request for business: depends on your payment.

We can find the above information from developers.google.com/maps/documentation/staticmaps/#api_key.

Thanks
Mark

I really don’t foresee using more than 1000 requests but I will try. Where would I enter the API Key in the GoogleOverlay? There is no method to enter the API Key.

Hi Chad,

The private key is available when using GoogleLayer, please try to use below code.

    @{Html.ThinkGeo().Map("Map1", 1000, 800)
       .MapUnit(GeographyUnit.Meter)
       .MapTools(mapTools =>
       {
           mapTools.OverlaySwitcherMapTool().Enabled(true);
       })
       .CustomOverlays(overlays =>
       {              
           overlays.LayerOverlay("GoogleMaps").Layer(new GoogleMapsLayer("GoogleRoadMapCache", "Your client id", "Your private key") { MapType = GoogleMapsMapType.RoadMap });
           overlays.BingMapsOverlay("BingAerial").MapType(BingMapsStyle.Aerial).Name("Bing - Aerial");
           overlays.BingMapsOverlay("BingRoad").MapType(BingMapsStyle.Road).Name("Bing - Road");
           overlays.BingMapsOverlay("BingHybrid").MapType(BingMapsStyle.Hybrid).Name("Bing - Hybrid");
           overlays.OpenStreetMapOverlay("OpenStreetMaps").Name("OpenStreetMaps");
       })
       .Render();
    }

If there is still meet this issue, please let us error message and stack trace, we can help to figure out this.

Thanks
Mark

Using the LayerOverlay method works but it is tremendously slower than the GoogleOverlay method. Also the LayerOverlay has watermarks all over the place where as the GoogleOverlay does not. I’m just really confused as to why the GoogleOverlay works from my machine locally but when I use the code on our server it crashes the page. Do I need to update something (dll files, etc) on the server, or is it an SSL issue, or what?

Also the LayerOverlay method works with and without using an API key, so that is why I believe there is something else that is causing the error.

Hi Chad,

As I mentioned above, we tried to recreate your issue with GoogleOverlay but failed. So we provider this layer workaround. Base on you testing, it is every strange result, we want to dig more deep for this issue.
To help us to figure out your issue. Could you please provide below things:

  1. Your server OS system version.
  2. One simple executable project to recreate this issue, we can use that to deploy on our server to do the testing.
  3. Could you please record your test steps, make sure we are doing the same testing.

Thanks
Mark

Running Windows Server 2012 R2 Standard, 64bit.

I’ll work on a small project but it’s identical to the demo and the code I posted earlier in this thread.

Hi Chad,

If you can reproduce the problem, we still need the items mentioned by Mark:

  1. One simple executable project to recreate this issue, so we can use that to deploy on our server for testing.
  2. Please record your test steps, make sure we are doing the same testing.

Regards,

Don

I am still trying to figure this out. I got the Google Map to display on the server finally. It is incredibly slow but it does work. However, it will only work for a few hours then it will only show my map with a white background. I have tried using new API Keys, resetting the website, resetting the app pool, but nothing seems to work. I am using the GoogleMaps Embeded API setting so it should allow for unlimited requests for free. Why do you think it is so slow and whey do you think it fails after a few hours. Below is my code.

//cshtml page
overlays.LayerOverlay(“Google - Satellite”).Layer(new GoogleMapsLayer(“GoogleSatelliteCache”, “”, APIKEY) { MapType = GoogleMapsMapType.Satellite }).TileType(TileType.SingleTile);

Hi Chad,

Our developer build a sample based on your code and did a test, it looks the render speed is not so slow even we simulate a slow network environment and we also hadn’t reproduced the white map when today’s test.

Please see our test video https://www.screencast.com/t/MpLC0WtMKStb and as below is the test project GoogleMapsLayerTest.zip (82.8 KB) ,you can run it and see whether this sample still can reproduce your issue. Please replace the Google key with yours before test.

Use proxy to connect to Google’s server is helpful to improve the load speed, we also have related code in sample project about it. Please notice the comment text in project.

Regards,

Ethan