VE Team
01-03-2008, 02:00 AM
<p><strong>Dragging entities on the map object</strong><br>A common request from developers is how to implement dragable map objects on the VE map Control. Virtual Earth supports a number of events on the map object (onmousedown, onmouseup, onmousemove in particular) that make it easy to implement dragging of elements on the map. Grayson Myers and Derrick Quan contributed some nice code samples to illustrate how to use these three events together for seamless drag of pushpins and polygons. Here are the samples - <ul> <li><a href="http://www.veteam.members.winisp.net/dragndrop/simpledrag.html" target="_blank">Simple Drag</a> - Draws a default and a custom pushpin and allows re-positioning of either of them <li><a href="http://www.veteam.members.winisp.net/dragndrop/Collectiondrag.html" target="_blank">Collection Drag</a> - Loads a Collection of travel destinations, each member of which is dragable <li><a href="http://www.veteam.members.winisp.net/dragndrop/shapedrag.html" target="_blank">Shape Drag</a> - Shows how to drag shapes and lines. slightly more complex in that the onmousemove event needs to recalculate the new pixel coordinate of each vertex for the shape being dragged</ul> <p>In each example, there's basically 2 pieces of code that are interesting. first, register the 3 events when initializing the map control like this: <p><font face="Courier New" color="#000000">map.AttachEvent("onmousedown",MouseHandler);<br>map.AttachEvent("onmouseup",MouseHandler);<br>map.AttachEvent("onmousemove",MouseHandler);</font> <p>All three events will fire MouseHandler <p><font face="Courier New" color="#000000">function MouseHandler(e)<br>{<br>** var msg;<br>** if (e.eventName == "onmousedown" && e.elementID != null)<br>** {<br>***** dragShape = map.GetShapeByID(e.elementID);<br>***** return true; // prevent the default action<br>** }else if (e.eventName == "onmouseup")<br>** {<br>***** dragShape = null;<br>** }else if (e.eventName == "onmousemove" && dragShape != null)<br>** {<br>***** var x = e.mapX;<br>***** var y = e.mapY;<br>***** pixel = new VEPixel(x, y);<br>***** var LL = map.PixelToLatLong(pixel);<br>***** dragShape.SetPoints(LL);<br>***** return true; // prevent the default action<br>** }<br>}</font> <p><strong>Web.Maps.VE ASP.NET Ajax library updated<br></strong>A new version of this Server control for your ASP.NET apps is out. Read about the <a href="http://pietschsoft.com/Blog/Post.aspx?PostID=1441" target="_blank">latest version here</a> featuring support for .NET 3.5 and <a href="http://simplovation.com/Page/WebMapsVE.aspx" target="_blank">visit the Simplovation website</a> to download it and view demos. If you want to keep most of your VE coding server-side this should be a helpful library.<img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=3151506992847969176&page=RSS%3a+Developer+news+for+Virtual+Earth%3a+Dr agging+Map+Elements+and+Web.Maps.VE+updated&referrer=" width="1px" height="1px" border="0" alt=""><img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&NA=1149&PI=73329&RF=&DI=3919&PS=85545&TP=virtualearth.spaces.live.com>1=virtualearth">
Click here to view the full post. (http://virtualearth.spaces.live.com/Blog/cns!2BBC66E99FDCDB98!10254.entry)
Click here to view the full post. (http://virtualearth.spaces.live.com/Blog/cns!2BBC66E99FDCDB98!10254.entry)