Tone down the highlighting of Nominatim search results
authorTom Hughes <tom@compton.nu>
Thu, 18 Jul 2013 14:29:01 +0000 (15:29 +0100)
committerTom Hughes <tom@compton.nu>
Thu, 18 Jul 2013 14:29:01 +0000 (15:29 +0100)
app/assets/javascripts/browse.js
app/assets/javascripts/index.js
app/assets/javascripts/map.js.erb

index cde7c12..edfb464 100644 (file)
@@ -74,33 +74,36 @@ $(document).ready(function () {
       object.version = params.version - 1;
     }
 
-    addObjectToMap(object, true, function(extent) {
-      $("#loading").hide();
-      $("#browse_map .geolink").show();
-
-      if (extent) {
-        $("a.bbox[data-editor=remote]").click(function () {
-          return remoteEditHandler(extent);
-        });
-
-        $("a.object[data-editor=remote]").click(function () {
-          return remoteEditHandler(extent, params.type + params.id);
-        });
-
-        $("#object_larger_map").show();
-        $("#object_edit").show();
-
-        var centre = extent.getCenter();
-        updatelinks(centre.lng,
-                    centre.lat,
-                    16, null,
-                    extent.getWest(),
-                    extent.getSouth(),
-                    extent.getEast(),
-                    extent.getNorth(),
-                    object);
-      } else {
-        $("#small_map").hide();
+    addObjectToMap(object, {
+      zoom: true, 
+      callback: function(extent) {
+        $("#loading").hide();
+        $("#browse_map .geolink").show();
+
+        if (extent) {
+          $("a.bbox[data-editor=remote]").click(function () {
+            return remoteEditHandler(extent);
+          });
+
+          $("a.object[data-editor=remote]").click(function () {
+            return remoteEditHandler(extent, params.type + params.id);
+          });
+
+          $("#object_larger_map").show();
+          $("#object_edit").show();
+
+          var centre = extent.getCenter();
+          updatelinks(centre.lng,
+                      centre.lat,
+                      16, null,
+                      extent.getWest(),
+                      extent.getSouth(),
+                      extent.getEast(),
+                      extent.getNorth(),
+                      object);
+        } else {
+          $("#small_map").hide();
+        }
       }
     });
   }
index 98f24a6..9f0c864 100644 (file)
@@ -40,7 +40,7 @@ $(document).ready(function () {
   }
 
   if (params.object) {
-    addObjectToMap(params.object, params.object_zoom);
+    addObjectToMap(params.object, { zoom: params.object_zoom });
   }
 
   handleResize();
@@ -59,7 +59,7 @@ $(document).ready(function () {
     }
 
     if (data.type && data.id) {
-      addObjectToMap(data, true);
+      addObjectToMap(data, { zoom: true, style: { opacity: 0.2, fill: false } });
     }
 
     if (marker) {
index 8b621e3..90aefa9 100644 (file)
@@ -96,7 +96,7 @@ function getUserIcon(url) {
   });
 }
 
-function addObjectToMap(object, zoom, callback) {
+function addObjectToMap(object, options) {
   if (objectLoader) {
     objectLoader.abort();
   }
@@ -110,13 +110,10 @@ function addObjectToMap(object, zoom, callback) {
     dataType: "xml",
     success: function (xml) {
       objectLayer = new L.OSM.DataLayer(null, {
-        style: {
-          strokeColor: "blue",
-          strokeWidth: 3,
-          strokeOpacity: 0.5,
-          fillOpacity: 0.2,
-          fillColor: "lightblue",
-          pointRadius: 6
+        styles: {
+          node: options.style,
+          way: options.style,
+          area: options.style
         }
       });
 
@@ -136,12 +133,12 @@ function addObjectToMap(object, zoom, callback) {
 
       var bounds = objectLayer.getBounds();
 
-      if (zoom) {
+      if (options.zoom) {
         map.fitBounds(bounds);
       }
 
-      if (callback) {
-        callback(bounds);
+      if (options.callback) {
+        options.callback(bounds);
       }
 
       objectLayer.addTo(map);