ThinkGeo.com    |     Documentation    |     Premium Support

Google Hybrid Watermarks

Hello,

I’m currently using WMS and google overlays as a map background. I’m only using google because WMS is quite slow.

To show the overlay I use the following code:

                string GoogleApiKey = "AIzaSyA_eRW037aBBKdL24vfx0FmYTqb6RWaD20";
                //Sets the projection parameters to go from Geodetic (EPSG 4326) or decimal degrees to Google Map projection (Spherical Mercator).  
                switch (this.ExtentProjection)
                {
                    case ExtentProjections.LatLong:
                        //need to change over to google's extent coordinate system
                        Proj4Projection proj4 = new Proj4Projection();
                        proj4.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326);
                        proj4.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString();
                        proj4.Open();
                        RectangleShape googleExtents = proj4.ConvertToExternalProjection(winformsMap1.CurrentExtent);
                        proj4.Close();
                        winformsMap1.MapUnit = GeographyUnit.Meter;
                        winformsMap1.CurrentExtent = googleExtents;
                        this.ExtentProjection = ExtentProjections.Google;
                        break;
                    case ExtentProjections.Google:
                        //shouldn't need to do anything...not sure how this case is possible
                        break;
                }

                string GoogleCacheLocation = MyUtilities.GetCropViewGoogleCacheFolder();
                this.GoogleOverlay = new GoogleMapsOverlay(GoogleCacheLocation, "", GoogleApiKey);
                this.GoogleOverlay.DrawingExceptionMode = DrawingExceptionMode.DrawException;
                this.GoogleOverlay.MapType = GoogleMapsMapType.Hybrid;
                this.GoogleOverlay.IsVisible = true;

This seems to work fine except that the maps have a bunch of watermarked strips on the images. Is there a way to make google return only one watermark per map? It seems ridiculous to have so many.

Thanks,
Mark

Hi Mark,

Please comment your ApiKey, because here is a public community.

If you want to reduce the logo number, you should use GoogleMapsLayer instead of GoogleMapsOverlay.

You can put the GoogleMapsLayer into LayerOverlay, and set the tileWidth and tileHeight to a bigger size, which can reduce the logo number.

Regards,

Don

Thanks for replying Don,

So using GoogleMapsLayer instead of GoogleMapsOverlay does seem to reduce to watermarks. If I set the tileHeight to say 2000 or like this:

                GoogleMapsLayer gmapLAyer = new GoogleMapsLayer(GoogleCacheLocation, "", GoogleApiKey);
                gmapLAyer.MapType = GoogleMapsMapType.Hybrid;
                //gmapLAyer.TileWidth = (int)winformsMap1.CurrentExtent.Width;
                gmapLAyer.TileHeight = (int)winformsMap1.CurrentExtent.Height;
                LayerOverlay gOver = new LayerOverlay();
                
                gOver.Layers.Add(gmapLAyer);
                winformsMap1.Overlays.Add(gOver);

It looks pretty nice until you pan or soom out of the immediate area. It seems like only the area originally within tileHeight is displayed:

Any ideas? I guess there’s probably some kind of onZoom() or onPan() event where I could change the tileHeight or force a new tile to load or something.

Thanks,
Mark

Hi Mark,

It looks Google have a limit for size here: https://developers.google.com/maps/documentation/static-maps/intro#Imagesizes

In fact I suggest you render the tile as 512 x 512.

And your problem should caused by your original cache. Before you make sure the tile size, please delete all original cache.

Regards,

Don

Ok, guess that’ll have to do for now.

Thanks,
Mark

Hi Mark,

I am glad to hear that’s helpful.

Regards,

Don