Dear Group,
I've recently begun to experiment with Virtual Earth. I do a fair amount of JavaScript programming in my real job; so I created a rudimentary script to allow me to plot a polygon representing a political district in my city. I'm an alderman running for re-election and I got interested in Virtual Earth as a means to make an on-line map of aldermanic districts.
Anyway, here is my rudimentary page:
http://www.swerbach.com/Neenah3rd/NeenahAldermanicDistricts1and3.htm
Summary of functions:
Start: Start recording mouse click positions as LatLong pairs
Stop: Stop recording mouse clicks
Del Last Line: Remove last polyline drawn on the map
Display: Show recorded mouse clicks in new window
So click the 'Start' button and begin clicking. A green line will be drawn beginning with your second click. Click 'Stop' and then 'Display' and you'll be able to copy and paste the LatLong co-ordinates into a web page JavaScript function to be able to plot a polygon.
Crude, I know. But this was before I found the local.live.com page and its nifty drawing capability. When I did find it I made a better drawing of District 3:
http://local.live.com/ v=2&cid=CC1CCBE382D8B5C8!103
(It'll take a moment to load the map with its two dozen-odd pushpins.)
When I'm signed on, of course, I can edit that polygon directly point-by-point. Very nice capability.
What I want to do, though, is be able to draw the 3 Districts in my city using the local.live.com on-line drawing capability...and then "capture" the LatLong pairs for those polygons and transfer them to my own web page.
Right now, if you look at the code for that local.live.com link, you'll see an XML polygon:
< xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" />
<v:shape id=msftve_1001_200016_50000
style="Z-INDEX: 60; LEFT: 0px; WIDTH: 718px; POSITION: absolute; TOP: 105px; HEIGHT: 455px"
unselectable="off" coordsize = "718,455" fillcolor = "lime" strokecolor = "blue" strokeweight = "2pt"
path = " m464,43 l453,44, 452,41, 430,41, 430,44, 415,44, 400,44 ... etc. ...
That's all well and good if one is only concerned with that particular zoom level. Of course a new XML shape is created for each Zoom level in the site's ASP.NET code or JavaScript code or whatever.
But is there a way for me, again, to "capture" the LatLong pairs for all of those co-ordinate points The polygon I'm able to draw on the local.live.com site is SO much better than the one I can draw with my rudimentary JavaScript.
Any hints
Regards,
Steve Erbach, Neenah, WI
http://TheTownCrank.blogspot.com

Somehow deriving an AddPolygon() from a Live Search Collection
xRuntime
John,
Very interesting! I'm going to look at that more in depth when I get home. Thank you!
Regards,
Steve Erbach
Neenah, WI
http://TheTownCrank.blogspot.com
DrScheme
Derek,
Yes, I saw that DrawPolygon enhancment! Very nice.
Maybe I'll have to settle for that enhancement, though I just remembered: isn't there a function in the VE API that converts pixel position to LatLong I'm going to look that up...
Regards,
Steve Erbach
Neenah, WI
http://TheTownCrank.blogspot.com
RTodd
John,
I looked at that Google Maps polyline utility and I think that might fill the bill for making a nice, accurate set of Lat/Long pairs. With those I can make the polygons I want on the VE site. Thanks for pointing that out.
Regards,
Steve Erbach
Neenah, WI
http://TheTownCrank.blogspot.com
Steve Graber
Derek,
Ah! We'll have to see if it's fixed then, eh Thanks.
Regards,
Steve Erbach
Neenah, WI
http://TheTownCrank.blogspot.com
Stephan Smetsers
3456
Well theres mapcruncher, although i haven't experimented with it yet, you can overlay a transparent image of what you want over the map. Here's the link to help out:
http://research.microsoft.com/mapcruncher/
Also something to improve your tool: an article on how to preview the next point you draw, and act more like the maps.live.com version.
http://viavirtualearth.com/wiki/DrawPolygon.ashx
Jared2000
No time to explain it this week but try this out:
Use this utility to get the encoded string for your polygon:
http://www.google.com/apis/maps/documentation/polylineutility.html
and use it in VE like this:
// Decode an encoded string into a list of VE lat/lng.
function
decodeLine(encoded) { var len = encoded.length; var index = 0; var array = []; var lat = 0; var lng = 0; try{
while (index < len) { var b; var shift = 0; var result = 0; do {b = encoded.charCodeAt(index++) - 63;
result |= (b & 0x1f) << shift;
shift += 5;
}
while (b >= 0x20); var dlat = ((result & 1) ~(result >> 1) : (result >> 1));lat += dlat;
shift = 0;
result = 0;
do {b = encoded.charCodeAt(index++) - 63;
result |= (b & 0x1f) << shift;
shift += 5;
}
while (b >= 0x20); var dlng = ((result & 1) ~(result >> 1) : (result >> 1));lng += dlng;
array.push(
new VELatLong((lat * 1e-5), (lng * 1e-5)));}
}
catch(ex){
//error in encoding.}
return array;}
function
AddPolygons() //add the hardcoded polygon info to the map once on load.{
var polyID = 0; var SatPoly = new Array();SatPoly.push(
"wlncF~slhVfC~bCo}AhRgIu~BxaBsV");SatPoly.push(
"wlncF~slhVv@{dBo`CpVfZ|dBxaBsV"); for (var x=0; x<SatPoly.length; x++){
poly =
new VEPolygon(polyID++,decodeLine(SatPoly[x]));poly.SetOutlineWidth(3);
poly.SetOutlineColor(
new VEColor(79, 64, 242, 1.0));poly.SetFillColor(
new VEColor(79, 64, 242, 0.3));map.AddPolygon(poly);
}
}
I'm tring to make some time to write this up nicely and maybe even do a VE version of the utility.
John.
ryan.rogers
Steve,
I've been so busy recently but set aside some time ot write up an article:
http://www.soulsolutions.com.au/Articles/Encodingforperformance/tabid/96/Default.aspx
John.