]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/index/notes.js.erb
Use new Leaflet setPopupContent method
[rails.git] / app / assets / javascripts / index / notes.js.erb
index 7e197b09e22b52fa1e747a9efe7c8446bc371ebb..6a7c50373d8173207c0e7439d45d55a15c3d64e4 100644 (file)
@@ -7,18 +7,18 @@ $(document).ready(function () {
   var noteIcons = {
     "new": L.icon({
       iconUrl: "<%= image_path 'new_note_marker.png' %>",
-      iconSize: [22, 22],
-      iconAnchor: [11, 11]
+      iconSize: [25, 40],
+      iconAnchor: [12, 40]
     }),
     "open": L.icon({
       iconUrl: "<%= image_path 'open_note_marker.png' %>",
-      iconSize: [22, 22],
-      iconAnchor: [11, 11]
+      iconSize: [25, 40],
+      iconAnchor: [12, 40]
     }),
     "closed": L.icon({
       iconUrl: "<%= image_path 'closed_note_marker.png' %>",
-      iconSize: [22, 22],
-      iconAnchor: [11, 11]
+      iconSize: [25, 40],
+      iconAnchor: [12, 40]
     })
   };
 
@@ -87,7 +87,7 @@ $(document).ready(function () {
     if (marker)
     {
       marker.setIcon(noteIcons[feature.properties.status]);
-      marker._popup.setContent(createPopupContent(
+      marker.setPopupContent(createPopupContent(
         marker, feature.properties, 
         $(marker._popup._content).find("textarea").val()
       ));
@@ -96,7 +96,7 @@ $(document).ready(function () {
     {
       marker = L.marker(feature.geometry.coordinates.reverse(), {
         icon: noteIcons[feature.properties.status],
-        opacity: 0.7
+        opacity: 0.9
       });
 
       marker.addTo(noteLayer).bindPopup(
@@ -115,7 +115,7 @@ $(document).ready(function () {
     var size = bounds.getSize();
 
     if (size <= OSM.MAX_NOTE_REQUEST_AREA) {
-      var url = "/api/" + OSM.API_VERSION + "/notes.json?bbox=" + bounds.toBBOX();
+      var url = "/api/" + OSM.API_VERSION + "/notes.json?bbox=" + bounds.toBBoxString();
 
       if (noteLoader) noteLoader.abort();
 
@@ -151,7 +151,7 @@ $(document).ready(function () {
       minWidth: 320,
       maxWidth: mapSize.y * 1 / 3,
       maxHeight: mapSize.y * 2 / 3,
-      offset: new L.Point(0, -3),
+      offset: new L.Point(0, -40),
       autoPanPadding: new L.Point(60, 40)
     };
   }
@@ -202,6 +202,8 @@ $(document).ready(function () {
         text: $(form.text).val()
       },
       success: function (feature) {
+        $(marker._popup._content).find("textarea").val("");
+
         notes[feature.properties.id] = updateMarker(marker, feature);
         newNote = null;
 
@@ -229,7 +231,7 @@ $(document).ready(function () {
           var popupContent = createPopupContent(marker, feature.properties);
 
           marker.setIcon(noteIcons[feature.properties.status]);
-          marker._popup.setContent(popupContent);
+          marker.setPopupContent(popupContent);
         }
       }
     });
@@ -262,7 +264,7 @@ $(document).ready(function () {
 
     newNote = L.marker(map.containerPointToLatLng(markerPosition), {
       icon: noteIcons["new"],
-      opacity: 0.7,
+      opacity: 0.9,
       draggable: true
     });