Skip to content

Instantly share code, notes, and snippets.

@sudheesh001
Created June 24, 2016 09:28
Show Gist options
  • Save sudheesh001/902f66645d3ef4e63038279eda7be98b to your computer and use it in GitHub Desktop.
Save sudheesh001/902f66645d3ef4e63038279eda7be98b to your computer and use it in GitHub Desktop.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Lets Drag a Marker Ria</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"></script>
<script type="text/javascript">
var map = null;
function getMap()
{
map = new Microsoft.Maps.Map(document.getElementById('myMap'), {credentials: 'Your Bing Maps Key', mapTypeId: Microsoft.Maps.MapTypeId.road, zoom:18});
attachPushpinDragEndEvent();
}
function attachPushpinDragEndEvent()
{
var pushpinOptions = {draggable:true};
var pushpin= new Microsoft.Maps.Pushpin(map.getCenter(), pushpinOptions);
var pushpindragend= Microsoft.Maps.Events.addHandler(pushpin, 'dragend', endDragDetails);
map.entities.push(pushpin);
alert('stop dragging newly added pushpin to raise event');
}
endDragDetails = function (e)
{
alert("Event Info - start drag \n" + "Start Latitude/Longitude: " + e.entity.getLocation() );
}
</script>
</head>
<body onload="getMap();">
<div id='myMap' style="position:relative; width:400px; height:400px;"></div>
<div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment