Browse files

re-added drag functionality

  • Loading branch information...
1 parent dff1a95 commit 1625be36d3037772166f9fd7646141412002783f @SpencerCooley committed Sep 5, 2012
Showing with 9 additions and 9 deletions.
  1. +9 −9 js/script.js
View
18 js/script.js
@@ -81,7 +81,7 @@ map.addLayer(polygon);
map.on('click', function(e) {
- var marker = new L.Marker(e.latlng);
+ var marker = new L.Marker(e.latlng, {draggable: true});
polygonPoints.push(e.latlng);
var markerId = polygonPoints.length -1
map.addLayer(marker);
@@ -96,6 +96,14 @@ map.on('click', function(e) {
var data = {latitude: e.latlng.lat , longitude: e.latlng.lng}
$('#latitude_longitude').append(template(data));
+ marker.on('drag', function(){
+ var locationWhileDrag = marker.getLatLng();
+ $('#first_marker').val(locationWhileDrag);
+ polygonPoints.splice(markerId,1,locationWhileDrag);
+ polygon.setLatLngs(polygonPoints);
+ });
+
+
});
//ends the click function
@@ -196,11 +204,3 @@ $("#address").autocomplete({
- // marker.on('drag', function(){
- // var locationWhileDrag = marker.getLatLng();
- // $('#first_marker').val(locationWhileDrag);
- // polygonPoints.splice(markerId,1,locationWhileDrag);
- // polygon.setLatLngs(polygonPoints);
- // });
-
-

0 comments on commit 1625be3

Please sign in to comment.