bhowden


This is really two questions. What I started out trying to do was zoom to a given bounding box. I ended up calculating the center, the width in pixels, projecting my bounding box to a projection in meters and calculating the required m/pixel. From that, it is easy to get the zoom level that will include the bounding box. Is there a more obvious way and the second question is how do you get a fractional zoom level When using the mouse scroll wheel, the map zooms in much smaller increments than the zoom levels (in fact, it doesn't even move the zoom indicator). Fractional zoom settings are ignored. Is there any way to specify a zoom of 13.5

Brian





Re: Zooming to fractional zoom levels

SoulSolutions


Brian,

VE is based on pre-rendered image tiles, that is what makes it so fast and so scalable. Because of this, within html, there is no way to do half zoom levels.

Have a look at : http://viavirtualearth.com/vve/Articles/WorldWind.ashx

It gives a good introduction to the tiles.

That said, something would be possible if you used the tiles at a non native resolution, but this is no supported in VE and would be very challanging to do.

By the way there is a built in bound box, either draw the box using your mouse middle button (typically the scrollwheel) or hold down Alt.

John.







Re: Zooming to fractional zoom levels

bhowden

>>>VE is based on pre-rendered image tiles, that is what makes it so fast and so scalable. Because

>>> of this, within html, there is no way to do half zoom levels.

That was my first assumption until I saw that the scroll wheel does partial zoom levels. I assume they go to the next lowest level of resolution and stretchblt it to fit the window.

In my case, I wanted a programatic way to zoom to a bounding rectangle. We have an existing mapping application and I want to offer the user the option to "see it in 3D". To do this, I want to take the current bounding box from our app and launch VE at that location (and draw in any features that the user has selected).

Brian







Re: Zooming to fractional zoom levels

SoulSolutions

Ah of course in 3D mode it is not HTML and it can scale the image tiles.

var m=map.GetMapMode();
if (m==VEMapMode.Mode3D)
{
map.SetAltitude(20000);
map.SetPitch(-33);
map.SetHeading(175);
}

You can actually set it whatever altitude, pitch and heading you like.

Now to turn a bounding box into an altitude you will need some maths (remember the world is not flat) and the height/width of the client map.

John.






Re: Zooming to fractional zoom levels

bhowden

>>>>Use altitude.

Hmmm. Good idea. Sure enough, there seems to be a relationship between altitude and what I want. As you go up and down, the zoom level changes as necessary and it stretches in between zoom levels. It does not seem to be as simple as camera angle or a relationship between altitude and visible area though. If you stay at the same altitude and look at a square client window you can measure the width of the view. If you resize the window to be the same width but much taller, you see much less width in the view. In other words, if you are printing out the GetMapView() width in degrees longitude, you get less in the window as the window gets taller. Not sure why aspect ratio of the client would affect this....

Brian






Re: Zooming to fractional zoom levels

SoulSolutions

By height/width I meant the size of the clients window not height divided by width = aspect ratio. Sorry to be confusing.

Its a pity you can't supply a viewport in the spec.

http://dev.live.com/virtualearth/sdk/ref/HTML/C_Namespace_VEMapViewSpecification_ctor.htm

I have done a bit of work recently with proper drawing circles on the earth and can tell you the math involved is not trival, I suspect working out the altitude may not be simple trig the old: a2 + b2 = c2, as the atitude is calulated from the centre lat/lon and the earth is curved (it will be closer)

This is a good reference:

http://www.movable-type.co.uk/scripts/LatLong.html

and maybe my circle stuff will give you an idea of what is involved:

http://www.viavirtualearth.com/wiki/Draw+a+circle.ashx

Let me know how you go.

John.






Re: Zooming to fractional zoom levels

bhowden

I think my problem is much simpler than yours with one hitch and one bit I still don't understand. There seems to be a one to one relationship between (2^ zoom level) and elevation. There is a one to one relationship between (2^ zoom scale) and m/pixel. Since I am coming from a projected window (in meters) and going to the mercator projection in VE (in meters), I don't think curvature will affect me. Even if it did, most of my numbers are < 100 km ground scale so the effect isn't to noticable. I do have the problem of my projection being different so as I move away from the centeral meredian of my projection, the view will rotate a bit but that is accounted for by the bounding box coming out a tiny bit larger. If I did my arithmetic correctly, this works out to:

altitude[in meters] = (654.1 * distance[in meters X or Y])/cos(latitude) * client pixels (width or height).

If I test the x and the y separately and take the largest elevation my window should be the minimum bounding rectangle that will include the old view. The hitch is that elevation in the control is above the geoid and the altitude in the calculation is the distance above the terain so I need the elevation of the terain to adjust. The window.status method of getting the elevation is a bit of a kludge as other parts of my app are updating it as well and the control seems to update it asyncronously.

The part I still don't understand is if I set the client size to be square and pick a location out in the middle of the ocean and get the view, zoom level, and elevation I get one set of numbers. If I leave everything the same and change the height to twice the width, same center, same zoom level, I get the same elevation but a different width (in degrees). Since the m/pixel is fixed, the same width client should return the same width on the ground but it is way off (say 20% at the zoom level I tested at). I must be missing something simple here but I don't see it rigtht now.

Brian






Re: Zooming to fractional zoom levels

SoulSolutions

Nothing is every simple Brian, but we all need challengers

Unfortunaly I know of no other way to get the elevation information, but you can always fix that bit when something a little less kludgy appears.

I don't quite understand what your issue is but your probably best to muddle your way through it, i recommend lots of drawing. Feel free to keep posting what your stuck on / how you are going and if I have anything to add/help i will. There are some GIS people floating around that may also lend some advice.

John.






Re: Zooming to fractional zoom levels

bhowden

I have not tried this yet but I suspect that this is a special case and getting the elevation might be fairly simple. If I zoom to the correct map center and check the zoom level (from which I can calculate elevation above terain) and then check elevation (over the geoid) I can get the terain elevation by taking the difference. This means I have to do it in two steps. One to set the map center and then another to zoom to the correct elevation. What might screw me up is the asyncronous nature of the api's. It would appear you can perform an operation and then read a property and the property does not always immediatly reflect the new state. (can anybody confirm this or am I suffering from brain fades ) I am assuming that the control is spinning off a thread and not necessarily blocking until it finishes. If this is the case we almost need an api call that will block until all running threads have finished their work.... Since it sounds like V5 might be fairly near I am waiting to see if any new api's solve my problems....

Again, not positive but I think the other bit I don't understand is related to the wording of the FAQ on projections. The implication is that there is a relationship between m/pixel and zoom level. I am beginning to suspect that this is only true for the largest dimention of the control. Sort of like using a fixed camera lens focal length to determine what is visible and then placing a view port over the visible area. Unless the view port is square, part of the visible area will be clipped. Can anybody confirm or debunk this one

Brian