Hi,
I’m trying to download a image from a custom map server which returns me a PNG of administrative borders. I made a class derived from GoogleMapsOverlay where i simply set the url to be used. The problem is that the returned image is “shifted”.
In instance, when I check an adress with a browser I get a correct image (see todo.png). However when I use the exact same url with my class I get a strange result (see done.png). It seems that my final result is shifted to the right.
Any idea why?
Here is the code below is this can help.
namespaceImageGeneration.Business{usingSystem.IO;usingSystem.Net;usingThinkGeo.MapSuite.Core;usingThinkGeo.MapSuite.WpfDesktopEdition;usingSystem.Globalization;usingSystem.Text;usingImageGeneration.Properties;
publicclassAdminUnitOverlay : GoogleMapsOverlay{publicAdminUnitOverlay(double? opacity,stringlayerName, RectangleShape rec,doublewidth,doubleheight){Opacity = opacity;LayerName = layerName;TileType = TileType.SingleTile;Url = GetImgUri(Settings.Default.DatastoreUrl, rec, width, height);this.SendingWebRequest += CustomGoogleMapsOverlay_SendingWebRequest;this.SentWebRequest += CustomGoogleMapsOverlay_SentWebRequest;}
publicdouble? Opacity {get;privateset; }
publicstringLayerName {get;privateset; }
publicstringUrl {get;privateset; }
voidCustomGoogleMapsOverlay_SentWebRequest(objectsender, SentWebRequestEventArgs e){//App.Calls++;//File.AppendAllText(@“c:\calls.txt”,“Calls: “+App.Calls.ToString()+”\r\n”);}
voidCustomGoogleMapsOverlay_SendingWebRequest(objectsender, SendingWebRequestEventArgs e){e.WebRequest = WebRequest.Create(Url);}
privatestringGetImgUri(stringserverUrl, RectangleShape tileExtent,doubletileWidth,doubletileHeight){var uriBuilder =newStringBuilder();
uriBuilder.Append(string.Format(“{0}?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&EXCEPTIONS=application/vnd.ogc.se_inimage&SRS={1}&FORMAT={2}&BBOX={3},{4},{5},{6}&WIDTH={7}&HEIGHT={8}”,serverUrl,“EPSG:900913”,“png32”,tileExtent.LowerLeftPoint.X.ToString(CultureInfo.InvariantCulture),tileExtent.LowerLeftPoint.Y.ToString(CultureInfo.InvariantCulture),tileExtent.UpperRightPoint.X.ToString(CultureInfo.InvariantCulture),tileExtent.UpperRightPoint.Y.ToString(CultureInfo.InvariantCulture),tileWidth,tileHeight));
uriBuilder.Append(string.Concat("&layers=", LayerName));
returnuriBuilder.ToString();}}}

