Zoom and Move to position

Jul 9, 2008 at 1:04 PM
Hi, First of all congrats on the project its awesome.

I want to zoom directly to a latlon position.
It works, but if i call it once the wrong position comes up.
so i call it in a loop, and its very slow....

Is there a better alternative?

Code snippet:
Msi.MoveTo(Location, ViewportWidth);

{Point
p = MapHelper.LatLongToPoint(ll, MSI);
Point zoomCenter = MSI.ElementToLogicalPoint(p);
zoomCenter.X = zoomCenter.X - ((MSI.ViewportWidth/10) * 5);
zoomCenter.Y = zoomCenter.Y - ((MSI.ViewportWidth/10) * 4);
MSI.ViewportOrigin = zoomCenter;
MSI.ViewportWidth = ViewportWidth;}


Greetz

 

Coordinator
Jul 10, 2008 at 12:46 AM
Edited Jul 10, 2008 at 12:48 AM
Well spotted - the public method we have exposed is "SetView" on the map object eg to Move to Brisbane, Australia:

map.SetView(

new Point {X = 153.03, Y = -27.47}, 14);

 

 

But you're right it looks like when it hits the right zoom level it no longer pans to the right spot, we need to fix the code in Map.cs function:

 

public void SetView(Point center, int zoomLevel)
{
IZoomLevelProvider zoomProvider = ZoomLevelProvider; 
if (zoomProvider != null && msi != null)
{
zoomLevel = zoomProvider.ValidateZoomLevel(zoomLevel);
Point pixel = Projection.ToDisplay(center, this, MapWidth);
pixel = TransformToVisual(msi).Transform(pixel);
Point logicalPoint = msi.ElementToLogicalPoint(pixel); 
Size mapSize = zoomProvider.GetMapSizeAtZoomLevel(zoomLevel); 
double ratio = msi.ActualWidth/mapSize.Width; 
double zoomFactor = msi.ViewportWidth/ratio;
msi.ZoomAboutLogicalPoint(zoomFactor, logicalPoint.X, logicalPoint.Y);
}
}

Aug 29, 2008 at 4:52 PM
Has the SetView function (in Jul 9 post by soulsolutions) been fixed yet???   Thanks.
Developer
Aug 29, 2008 at 11:56 PM
Edited Aug 29, 2008 at 11:58 PM
if you look in the post called "SetView end up on a blury map"

you will see a fix for "SetView" there

"Set UseSprings=false"

but then the map just goes directly to the new location and does not do all the fancy zooming stuff...

also if you read a few other posts you will see the guys are pretty busy doing there real life stuff and plan on making some updates in a couple weeks... ;)