Hi,
I downloaded daily eavalutaion build on 25 dec 2012. I saw an issue with google map.This release solved some performance issue drawing shapes over map.Plz resolve the issue with google maps.
Regards
Vivek
Hi,
I downloaded daily eavalutaion build on 25 dec 2012. I saw an issue with google map.This release solved some performance issue drawing shapes over map.Plz resolve the issue with google maps.
Regards
Vivek
Hi Vivek,
This is a bug in MapSuiteCore, I’ve assigned this to our development team. I’ll let you know if it has been fixed.
Regards,
Edgar
Hi,
I am trying to display Google maps as backdrop in my map window (followed the link thinkgeo.com/forums/MapSuite/tabid/143/aft/5155/Default.aspx). It gets displayed, but the map is zoomed out (In wpf, the IsSnapToZoomLevel property is not to be found)… and after doing a bit of navigation to view the map, it throws an error:
An unhandled exception of type ‘System.NotSupportedException’ occurred in PresentationCore.dll
Additional information: No imaging component suitable to complete this operation was found.
Am I doing it the right way?
-----------------------------------------
Following the code that I use:
wpfMap1.MapUnit = GeographyUnit.Meter;
GoogleMapsOverlay googleOverlay = new GoogleMapsOverlay(@“Key”, @“C:\GoogleCache”);
googleOverlay.MapType = GoogleMapsMapType.Terrain;
wpfMap1.Overlays.Add(googleOverlay);
// This sets the zoom levels to map to Googles. We next make sure we snap to the zoomlevels
wpfMap1.ZoomLevelSet = new ThinkGeo.MapSuite.Core.GoogleMapsZoomLevelSet();
//wpfMap1.IsSnapToZoomLevel = true;
// Zoom into the center of the map and zoom into the third zoom level.
wpfMap1.CenterAt(23, 23);
wpfMap1.ZoomToScale(wpfMap1.ZoomLevelSet.ZoomLevel12.Scale);
wpfMap1.Refresh();
-------------------------------------------------------------
Is there any solution for the above mentioned error?
Thanks,
Jacob
Hi Jacob,
I checked this link and found this article is a bit old as we did some API changes on GoogleOverlay those years. Please try the blow codes:
Map1.MapUnit = GeographyUnit.Meter;
GoogleMapsOverlay googleOverlay = new GoogleMapsOverlay();
//googleOverlay.ClientId = "clientid";
//googleOverlay.PrivateKey = "Your key";
googleOverlay.MapType = GoogleMapsMapType.Terrain;
Map1.Overlays.Add(googleOverlay);
// This sets the zoom levels to map to Googles. We next make sure we snap to the zoomlevels
Map1.ZoomLevelSet = new ThinkGeo.MapSuite.Core.GoogleMapsZoomLevelSet();
RectangleShape currentExtent = new RectangleShape(-13939426.6371, 6701997.4056, -7812401.86, 2626987.386962);
Map1.CurrentExtent = currentExtent;
// or we can use the below two line to locate the extent instead of using CurrentExtent property.
//Map1.CenterAt(currentExtent.GetCenterPoint());
//Map1.CurrentScale = Map1.ZoomLevelSet.ZoomLevel12.Scale;
Map1.Refresh();
Hi Troy,
I tried the code that you sent in the Window_Loaded event…
//----------------------------------
private void Window_Loaded(object sender, RoutedEventArgs e)
{
wpfMap1.MapUnit = GeographyUnit.Meter;
GoogleMapsOverlay googleOverlay = new GoogleMapsOverlay();
//googleOverlay.ClientId = “clientid”;
//googleOverlay.PrivateKey = “Your key”;
googleOverlay.MapType = GoogleMapsMapType.Terrain;
wpfMap1.Overlays.Add(googleOverlay);
// This sets the zoom levels to map to Googles. We next make sure we snap to the zoomlevels
wpfMap1.ZoomLevelSet = new ThinkGeo.MapSuite.Core.GoogleMapsZoomLevelSet();
RectangleShape currentExtent = new RectangleShape(-13939426.6371, 6701997.4056, -7812401.86, 2626987.386962);
wpfMap1.CurrentExtent = currentExtent;
// or we can use the below two line to locate the extent instead of using CurrentExtent property.
//Map1.CenterAt(currentExtent.GetCenterPoint());
//Map1.CurrentScale = Map1.ZoomLevelSet.ZoomLevel12.Scale;
wpfMap1.Refresh();
}
//--------------
It loaded google maps, but still when I try to zoom in or out a few times its throws error.
------------------------
An unhandled exception of type ‘System.NotSupportedException’ occurred in PresentationCore.dll
Additional information: No imaging component suitable to complete this operation was found.
{“No imaging component suitable to complete this operation was found.”}
-------------------------------
Is there something else to be taken care of? What could be the possible reason for the error.
Regards,
Jacob
Hi Jacob,
I think I also encounter your issue when I test and I guess it is a bug bringing recently. Our tracking team is working on it now. As a workaround, would you please try to use LayerOverlay rather than GoogleMapsOverlay? Actually, there is not a big differences between them.
GoogleMapsLayer googleLayer = new GoogleMapsLayer();
googleLayer.MapType = GoogleMapsMapType.Terrain;
LayerOverlay overlay = new LayerOverlay();
overlay.Layers.Add(googleLayer);
wpfMap1.Overlays.Add(overlay);
Hi Troy,
I tried the above code…The map got displayed but after some zoom in and out it showed the following error:
---------------------------------------------------------
An unhandled exception of type ‘System.AggregateException’ occurred in WpfDesktopEdition.dll
Additional information: One or more errors occurred.
System.AggregateException was unhandled
_HResult=-2146233088
_message=One or more errors occurred.
HResult=-2146233088
IsTransient=false
Message=One or more errors occurred.
Source=WpfDesktopEdition
StackTrace:
at ThinkGeo.MapSuite.WpfDesktopEdition.Tile.<>c__DisplayClass6.<DrawException>b__4()
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.Run()
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at System.Windows.Application.Run()
at HelloWorld.App.Main() in d:\Projects\HelloWorld\HelloWorld\obj\x86\Debug\App.g.cs:line 0
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: System.Net.WebException
_HResult=-2146233079
_message=The remote server returned an error: (403) Forbidden.
HResult=-2146233079
IsTransient=false
Message=The remote server returned an error: (403) Forbidden.
Source=System
StackTrace:
at System.Net.HttpWebRequest.GetResponse()
at ThinkGeo.MapSuite.Core.GoogleMapsLayer.SendWebRequestCore(WebRequest webRequest)
at ThinkGeo.MapSuite.Core.GoogleMapsLayer.SendWebRequest(WebRequest webRequest)
at ThinkGeo.MapSuite.Core.GoogleMapsLayer.fVs=(Object fls=)
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
InnerException:
------------------------------------------------------------
1) Are you getting the same error?
Now I am using BingMaps … There are no errors, but it takes time to load.
After loading BingMaps I load a KML file using the following code:
public void LoadKMLFile(string strFilename)
{
try
{
Proj4Projection proj_KML = new Proj4Projection();
proj_KML.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326);
proj_KML.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString();
string kmlFile = strFilename;
KmlFeatureLayer kmlLayer = new KmlFeatureLayer(kmlFile);
kmlLayer.FeatureSource.Projection = proj_KML;
kmlLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = new AreaStyle(new GeoPen(GeoColor.SimpleColors.Red), new GeoSolidBrush(GeoColor.SimpleColors.Red));
kmlLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = new LineStyle(new GeoPen(GeoColor.SimpleColors.Blue, 5));
kmlLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = new PointStyle(PointSymbolType.Circle, new GeoSolidBrush(GeoColor.SimpleColors.BrightRed), 10);
kmlLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
LayerOverlay KMLOverlay = new LayerOverlay();
KMLOverlay.Layers.Add(“KmlLayer”, kmlLayer);
wpfMap1.Overlays.Add(“KMLOverlay”, KMLOverlay);
wpfMap1.Overlays.MoveToTop(“KMLOverlay”);
wpfMap1.Refresh();
wpfMap1.CurrentExtent = kmlLayer.GetBoundingBox();
kmlLayer.Close();
wpfMap1.Refresh();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
This does not display the KML file. If I do not change the projection, it does display at a wrong area, but with the default style, not the ones mentioned in code.
2) Am I doing the reprojection and loading of KML in the right way?
Also, I need to display ECW and MrSid raster files after BingMaps are displayed.
3) How do I reproject them? I tried without reprojection, but none of them displays.
I had loaded and displayed the same kml, ecw and MrSid files before without any problem. Now I am trying to overlay them over BingMaps. Kindly advice.
Regards,
Jacob
Hi Jacob,
1). For google layer 403 issue, this is because there is a limit number for requesting tiles on google map server, there are three cases on it:
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}”);
}
Hi Troy,
Thank you for your reply.
I am able to display ecw and mrsid raster properly with reprojected coordinate system after changing the ImageSource.Projection.
I can send you the kml file that I am using to forumsupport@thinkgeo.com.
Also, I was getting the coordinates values using
void TrackOverlay_MapMouseMove(object sender, MapMouseMoveInteractiveOverlayEventArgs e)
{
txtCoordinates.Text = "X=" + e.InteractionArguments.WorldX.ToString("N4", CultureInfo.InvariantCulture) + ", Y=" + e.InteractionArguments.WorldY.ToString("N4", CultureInfo.InvariantCulture);
}
Before applying the Geography Unit as meter, I used to get values like
X=148.8106, Y=-30.6740
Since I updated to meter it returns me values like
X=16,565,528.2768, Y=-3,590,440.6990
How do I change it to the earlier format?
Thanks and regards,
Jacob
Hi Jacob,
Thanks for the kml file. The reason kml layer didn’t display is because we need to specify the StylingType as “StandardStyle”. By default, this property is “EmbeddedStyle”.
As for the mousemove event parameter, after we specify the unit as meter, then all the coordinates would be changed to meter. In order to rollback to decimal degree, we can do another projection conversion. The codes would be like:
void TrackOverlay_MapMouseMove(object sender, MapMouseMoveInteractiveOverlayEventArgs e)
{
Proj4Projection proj_KML = new Proj4Projection();
proj_KML.InternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString();
proj_KML.ExternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326);
PointShape projectedPosition = proj_KML.ConvertToExternalProjection(new PointShape(e.InteractionArguments.WorldX, e.InteractionArguments.WorldY));
txtCxoordinates.Text = “X=” + projectedPosition.X.ToString(“N4”, CultureInfo.InvariantCulture) + “, Y=” + projectedPosition.Y.ToString(“N4”, CultureInfo.InvariantCulture);
}
Thank you Troy.
That was really helpful.
Hi Jacob,
You’re welcome, if any questions, don’t hesitate to let us know.
Thanks,
Troy
Hi,
Is there a way to catch the exception thrown if the Bing maps key is incorrect or is expired? Now when I run the application in debug mode, I get the following error:
An unhandled exception of type ‘System.Net.WebException’ occurred in WpfDesktopEdition.dll
Additional information: The remote server returned an error: (401) Unauthorized.
If it is not in debug mode, the application crashes.
What could be the best posssible way to avoid this exception?
Thanks,
Jacob
Hi Jacob,
Because this exception thrown by a validation before get tile, so we cannot draw the exception on tile but only throw it to let user knows.
As below is a simple workaround:
private void WpfMap_Loaded(object sender, RoutedEventArgs e)
{
bool isValid = true;
try
{
WebRequest request = WebRequest.Create(“dev.virtualearth.net/REST/v1/Imagery/Metadata/Aerial?&incl=ImageryProviders&o=xml&key=yourkey”);
WebResponse response = request.GetResponse();
}
catch (Exception ex)
{
isValid = false;
}
if (isValid)
{
BingMapsLayer bingMapsLayer = new BingMapsLayer(“abc”, BingMapsMapType.Aerial);
Map1.MapUnit = GeographyUnit.Meter;
Map1.CurrentExtent = new RectangleShape(-200000, 200000, 200000, -200000);
LayerOverlay layerOerlay = new LayerOverlay();
layerOerlay.Layers.Add(bingMapsLayer);
Map1.Overlays.Add(“WMK”, layerOerlay);
Map1.Refresh();
}
}
Wish that’s helpful.
If you have any good suggestion about this please let us know.
Regards,
Don
Hi,
Please replace the "& amp ;" to "&" in url.
Regards,
Don
Hi Don,
The workaround was really useful. Thank you for that.
Regards,
Jacob
Hi Jacob,
Glad to hear that Don’s workaround works.
If any question, please feel free to let us know.
Thanks,
Kevin