HOW TO PROGRAMMATICALLY PAN TO SPECIFIC POINT - Printable Version
+- AB4D Forum (https://forum.ab4d.com)
+-- Forum: Products Forums (https://forum.ab4d.com/forumdisplay.php?fid=4)
+--- Forum: ZoomPanel (https://forum.ab4d.com/forumdisplay.php?fid=8)
+--- Thread: HOW TO PROGRAMMATICALLY PAN TO SPECIFIC POINT (/showthread.php?tid=4151)
HOW TO PROGRAMMATICALLY PAN TO SPECIFIC POINT - Shafferjb - 10-01-2019
I am using the ZoomPanel to navigate around a map image that is 21600x21600. The ZoomPanel itself is 2160x2952 (this is on a 4K display). On the map are markers (like GoogleMap markers). The location of the markers are relative to the map image, so a given marker's location might be 15850,9720.
In general, the zoom panel works great. However, based on user activity, I need to programmatically center a given marker in the viewbox (or as near to center as the map limits allows). I have tried all the various "Translate" methods, and none of them work as I would have expected. When I call the Translate methods, the map moves within the ZoomPanel, but it doesn't move where I expect it to.
For example, when I call TranslateToCenter(new Point(10800,10800)) or TranlateToCenterRelative(new Point(0.5, 0.5)), I would expect the map to move to the center of the map image , but it only moves the map a short (and seemingly random) distance towards the center.
What is the correct method of programmatically setting the center point to a specific x,y location, or getting the given x,y location as close to the center as possible without violating the Viewbox limits?
Here is the xaml for the ZoomPanel:
<ab2d:ZoomPanel x:Name="exploreMapZoom" IsViewboxLimited="True" ViewboxLimits="0 0 1 1" ViewboxMinSize="0.1 0.1" Stretch="UniformToFill" CenterPosition="0.5 0.5" CenterPositionUnits="Relative" IsAnimated="True">
<Grid x:Name="exploreMapGrid" Width="21600" Height="21600">
<Image x:Name="exploreMapImage" HorizontalAlignment="Left" VerticalAlignment="Top" Source="ExploreMap.jpg"/>
Attached is a screen capture of the map within the ZoomPanel, including a ZoomPanelDump.
RE: HOW TO PROGRAMMATICALLY PAN TO SPECIFIC POINT - abenedik - 10-01-2019
The TranslateToCenter and TranlateToCenterRelative methods are used to simulate the mouse panning.
To set a new center position you can simply call (this sample set the center to the center of the map - the CenterPositionUnits property must be set to Relative):
If you want to have animated panning to the new location you can use the SetZoom method:
RE: HOW TO PROGRAMMATICALLY PAN TO SPECIFIC POINT - Shafferjb - 10-01-2019
Calling "SetZoom" works perfectly. Thanks for the help!