L.Icon.Default.imagePath = <%= "#{asset_prefix}/images".to_json %>;
var map;
+var objectLayer;
var layers = [
{
}
function addObjectToMap(object, zoom, callback) {
+ if (objectLayer) {
+ map.removeLayer(objectLayer);
+ }
+
$.ajax({
url: OSM.apiUrl(object),
dataType: "xml",
success: function (xml) {
- var layer = new L.OSM.DataLayer(xml, {
+ objectLayer = new L.OSM.DataLayer(xml, {
style: {
strokeColor: "blue",
strokeWidth: 3,
}
});
- var bounds = layer.getBounds();
+ var bounds = objectLayer.getBounds();
if (zoom) {
map.fitBounds(bounds);
callback(bounds);
}
- layer.addTo(map);
+ objectLayer.addTo(map);
}
});
}
min_lat,max_lat,min_lon,max_lon = place.attributes["boundingbox"].to_s.split(",")
prefix_name = t "geocoder.search_osm_nominatim.prefix.#{klass}.#{type}", :default => type.gsub("_", " ").capitalize
prefix = t "geocoder.search_osm_nominatim.prefix_format", :name => prefix_name
+ object_type = place.attributes["osm_type"].to_s
+ object_id = place.attributes["osm_id"].to_s
@results.push({:lat => lat, :lon => lon,
:min_lat => min_lat, :max_lat => max_lat,
:min_lon => min_lon, :max_lon => max_lon,
- :prefix => prefix, :name => name})
+ :prefix => prefix, :name => name,
+ :type => object_type, :id => object_id})
@more_params[:exclude].push(place.attributes["place_id"].to_s)
end