Scale indication in may map

Txejo
09-19-2007, 10:36 AM
Hi!

Iīm programing in .Net 2.0 (C#) and MapPoint Web Service.
I canīt found the property to show the Scale in my map.

Iīll try to explain better...
I need to show the scale of the map I show like Virtual Earth and Google Maps do. That way the user can know the real size of what is seeing.

Thanks
Jon

Txejo
09-28-2007, 03:47 AM
Hi,

Here is my auto-answer, specting will be useful to someone.

MWS hasnīt got an Scale bar red:mad:!!!!

Ok, no matter, everything has a solution except what hasnīt. :bluewink:

The MapImage returned by the "renderService.GetMap(mapSpec)" has 3 views of the returned map, viewByScale has the Scale value. Depending on the unit you use (Miles or Kilometers, the second in my case) the Scale value (50000 for example) means that 1Cm. of the returned map equals 50000 cm. of what is representing. Or what is the same: "1:50000".

Assuming 96 dpi resolution (what is the most normal) 1cm = 37,795275591px (Itīs easy to find this value and the mile=px just search)
Now you have to choose what you wanna do with this values, if you going to have a scale bar with constant width or you want a variable width ajusting to some values.

What I do is this:
maxbar = 200px = Maximun scale bar width.
cmToPx = 37,795275591. Explained above.
scale= 30738cm = the scale value returned getting the map with my app starts

barToKm = (((maxbar /cmToPx )*scale)/100000) = how many km represents my bar with the maximun width.
km=Truncate(batToKm) = I donīt want to show decimal values
KmtoPx = (((km * 100000) / scale) * cmToPx) = How many pixels represents the truncated km value.

Now I draw a bar with KmToPx width; and a label with km.toString().

Thatīs All Folks :-P

Sorry for my bad english, and so long post.


Txejo.

 
Web mp2kmag.com
mapforums.com