ThinkGeo.com    |     Documentation    |     Premium Support

How to generate image file of isolines with map background

I have a web edition aspx page with the isolines layer. I also need to generate a similar map as an image file. The image generation logic is not directly on the map, but handled in C# code in a separate class. My existing code was written back in v7.x and has been upgraded along the way, now on v10.x. My current code uses the following:

  • MapEngine
  • GoogleMapsLayer (with hook for CreatingRequest event in order to insert API key into URL for map tiles)
  • BingMapsLayer
  • OpenStreetMapLayer
  • InMemoryFeatureLayer (this is built using GridFeatureSource.GenerateGridMatrix and IsoLineLayer.GetIsoFeatures)
  • LegendAdornmentLayer

I have a config option to select the Google/Bing/Open map type, so only one is used in each image. This works pretty well, but when using Google, the static map tiles have the Google watermark (“Google Imagery @2017”) on EACH tile. For example:

Is there a better way to do this, such that the the Google watermark is only at the bottom or top a single time? Since my code was written years ago, perhaps there is a better way to do this with v10?

Hi Randy,

For V10 we split most of the features in map to different packages in Nuget.Org. The simplest way to upgrade to V10 is install the standard package which contains all packages: https://www.nuget.org/packages/MapSuiteWebForWebForms-Standard/11.0.0-beta022 (It don’t contains MapEngine, please see the detail description later).

And you should want to visit the upgrade guide, which should be helpful if you met problem when try to upgrade to V10:
http://wiki.thinkgeo.com/wiki/map_suite_10_upgrade_guide

If you don’t want to add so many packages which may not been used, you can see my list as below:

  1. For MapEngine:
    The MapEngine is our old service edition, it can only works when you want to draw map in image, for V10 we removed it from our product, if you are using WebEdition, directly add layer in overlay, then add overlay in map, the map will be drawn in map control. If your scenario still need to use MapEngine, please view the code of MapEngine here: http://wiki.thinkgeo.com/wiki/_media/mapengine.zip1
    And I think this topic should be helpful: http://community.thinkgeo.com/t/how-do-i-save-the-map-as-image-in-thinkgeo-10/86341

  2. For GoogleMapsLayer:
    You just need install this package https://www.nuget.org/packages/ThinkGeo.MapSuite.Layers.GoogleMaps/11.0.0-beta009, the event name is SendingWebRequest now.

  3. For BingMapsLayer:
    Install this package https://www.nuget.org/packages/ThinkGeo.MapSuite.Layers.BingMaps/11.0.0-beta008

  4. For OpenStreetMapLayer:
    Install this package https://www.nuget.org/packages/ThinkGeo.MapSuite.Layers.OpenStreetMap/11.0.0-beta005

  5. For InMemoryFeatureLayer:
    It’s included in our map suite package, ThinkGeo.MapSuite, https://www.nuget.org/packages/ThinkGeo.MapSuite/11.0.0-beta041

  6. LegendAdornmentLayer:
    Install this package https://www.nuget.org/packages/ThinkGeo.MapSuite.Layers.Adornments/11.0.0-beta006

And I think you should want to install the web edition here: https://www.nuget.org/packages/MapSuiteWebForWebForms-BareBone/11.0.0-beta022

Please install them via the NuGet plugin in VS.

Remove the watermarker is no allowed by Google, the solution for that is choose SingleTile mode, or change the tile size from 256 x 256 to bigger size.

Wish that’s helpful.

Regards,

Ethan

Thank you for the info. I increased the tile size to 640x640, so it looks a little better now (nevermind the orange/yellow colors, I was experimenting with different data):

In this example, only one tile’s watermark is visible. That is an improvement, but it would still be much nicer to have the @2017 Google watermark at the very bottom corner, like in the web control.

By contrast, this is how it looks using the ThinkGeo.MapSuite.WebForms.Map web control. Notice how the Google logos align nicely at the bottom:

Is there any way to make the code-behind (e.g. MapEngine) generate the image that looks like that? It seems the GoogleOverlay looks better than the GoogleMapsLayer. Is there a way to use the GoogleOverlay to generate the image file?

Is my approach still the best approach for generating an image file outside of the ThinkGeo.MapSuite.WebForms.Map control itself? The approach of handling the event to inject the API key seems kind of awkward.

var glayer = new GoogleMapsLayer();
glayer.CreatingRequest += Glayer_CreatingRequest;

private void Glayer_CreatingRequest(object sender, CreatingRequestGoogleMapsLayerEventArgs e)
{
    e.RequestUri = new Uri(e.RequestUri.AbsoluteUri + $"&key={GoogleApiKey}");    
}

Is there a better way to do this?

Hi Randy,

For webforms edition, the GoogleOverlay is connect to Google map JavaScriptLibrary, and the GoogleMapsLayer is connect to Google map StaticLibrary. Download the tile images by map control from JavaScript library is also not allowed, just like remove or cover the watermarker from static tile images.

Have you tried to use SingleTile mode for GoogleMapsLayer?

And we still have the constructor: public GoogleMapsLayer(string cacheDirectory, string clientId, string privateKey);

If you have clientId and privateKey, you can directly pass in here.

We ever have another constructor to pass in only one key, but that asked to removed by Google.

Regards,

Ethan