/ Published in: HTML
**Important: this snipplet has moved to Github.**
- [Draggable Pushpins in Bing Maps AJAX 7.0](https://gist.github.com/1973138)
- [Draggable Pushpins in Bing Maps AJAX 7.0](https://gist.github.com/1973138)
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body onload="init();"> <script type="text/javascript"> // Event handlers function onStartDragPin(e){ console.log('dragstart'); } function onDragPin(e){ console.log('drag: ' + e.entity.getLocation()); } function onEndDragPin(e){ console.log('dragend'); } function init(){ // Load the map var map = new Microsoft.Maps.Map( document.getElementById("myMap"), { credentials: "YOUR-BING-KEY", mapTypeId: Microsoft.Maps.MapTypeId.road } ); // Create a draggable Pushpin var pin = new Microsoft.Maps.Pushpin( map.getCenter(), { draggable: true } ); // Listen to its drag-related events Microsoft.Maps.Events.addHandler(pin, 'dragstart', onStartDragPin); Microsoft.Maps.Events.addHandler(pin, 'drag', onDragPin); Microsoft.Maps.Events.addHandler(pin, 'dragend', onEndDragPin); // And add the pin to the map map.entities.push(pin); } </script> </body> </html>