Hi,
We are using the GetGeographicFromZoom(xamGeoMap.ActualWindowRect) to get the current geographic view and zoom and then persist this view.
When the user re-opens the Map, we need to Zoom back to the original view the user had.
To do this we use:
xamGeoMap.WindowRect = xamGeoMap.GetZoomFromGeographic(Settings.WindowRect); // Settings.WindowsRect being the rect we got from GetGeographicFromZoom as above.
This works to a certain extend, except that the Zoom is slightly zoomed out further than saved.
The map is center, but slightly zoomed out further than when we saved the current rect.
Are we approaching this incorrectly? Are we using the correct methods to persist and restore the viewport on the map?
Please advise urgently...
Hey Chris,
It's anticipated that resizing the component will cause a saved window rect to not display the correct position. A window rect is aspect ratio dependent, and if you have modified the aspect ratio in the interim, it wont restore the correct view, unless corrected for the aspect ratio change.
The simplest resolution is to store the geographic coordinates around the center point and restore those, but, as I see, you were having an issue with that. Looking into it, I believe this is actually due to a bug in converting back from geographic coordinates to window positioning whereby some additional coercion is being performed that doesn't look necessary to me, or warranted. We'll look into this further and likely write it up as a bug.
In the meantime, you should be able to use this workaround to avoid the extra coercion being performed on the provided geographic rectangle:
https://gist.github.com/gmurray81/7ddc3e53b858b2a794255fd5ff071315
Hope this helps!
-Graham
Now try the following: This works if your map control size does not change.
Save the settings, then resize your window to be smaller or larger than when you saved the setting.
NOW reload using the above approach and you will see the map does not center where you saved it.
Still no joy....
Hello Chris,
I attached sample app that saves and loads view parameters of the GeoMap using the ActualWindowRect property. Note that the Map automatically recalculates any value set to WindowRect property such that the center of saved map view is always displayed in plot area of the map. For example, if you zoom the map to such that all boarders of France are visible, save the map view, resize the map (or app window), load map view, then the map will adjust its internal WindowRect such that center of France is visible. This behavior cover most use cases for our customers. Please submit feature request if you would like to have other behaviors for resolving WindowRect of the GeoMap.
Thanks,
Martin
We tried all possible approaches as well as the one above. BUT, time is money and this control is not worth the effort.
Your suggestion ALMOST works, however, the zoom changes every time we restore the graph.
We went with an alternate provider which actually restores previous locations and zoom level perfectly.
Thanks for the effort though, maybe this will help someone else in the near future.
After reviewing this issue it has come to our attention that you should be saving xamGeoMap.ActualWindowRect property (not xamGeoMap.WindowRect) in the MapView and then setting it back to xamGeoMap.WindowRect property when you wish to load previsusly saved map view. Using GetGeographicFromZoom and then GetZoomFromGeographic method will not result in excacly the same window rect. Let me know if you have any questions.
Sincerely,
Michael Di FilippoAssociate Software DeveloperInfragistics, Inc.www.infragistics.com/support