cm.addTo(map);
}
+ var MapPositionControl = L.Control.extend({
+ options: {
+ position: 'bottomright'
+ },
+
+ onAdd: function (map) {
+ var container = L.DomUtil.create('div', 'my-custom-control');
+
+ $(container).text('show map bounds').addClass('leaflet-bar btn btn-sm btn-default').on('click', function(e){
+ e.preventDefault();
+ e.stopPropagation();
+ $('#map-position').show();
+ $(container).hide();
+ });
+ $('#map-position-close a').on('click', function(e){
+ e.preventDefault();
+ e.stopPropagation();
+ $('#map-position').hide();
+ $(container).show();
+ });
+
+ return container;
+ }
+ });
+
+ map.addControl(new MapPositionControl());
function display_map_position(mouse_lat_lng){
html_viewbox = "viewbox: " + map_viewbox_as_string();
- $('#map-position').html([html_center,html_zoom,html_viewbox,html_click,html_mouse].join('<br/>'));
+ $('#map-position-inner').html([html_center,html_zoom,html_viewbox,html_click,html_mouse].join('<br/>'));
$('input#use_viewbox').trigger('change');
}
var bounds = [[result.aBoundingBox[0]*1,result.aBoundingBox[2]*1], [result.aBoundingBox[1]*1,result.aBoundingBox[3]*1]];
map.fitBounds(bounds);
if (result.astext && result.astext.match(/(POLY)|(LINE)/) ){
- var layer = omnivore.wkt.parse(result.astext);
- layerGroup.addLayer(layer);
+ var geojson_layer = L.geoJson(null, {
+ // http://leafletjs.com/reference.html#geojson-style
+ style: function(feature) { return { clickable: false, color: 'blue' }; }
+ });
+ omnivore.wkt.parse(result.astext,null,geojson_layer);
+ layerGroup.addLayer(geojson_layer);
}
else {
// var layer = L.rectangle(bounds, {color: "#ff7800", weight: 1} );
map.addLayer(circle);
if ( nominatim_result.outlinestring ){
- var outline = omnivore.wkt.parse(nominatim_result.outlinestring);
- map.addLayer(outline);
- map.fitBounds(outline.getBounds());
+
+ var geojson_layer = L.geoJson(null, {
+ // http://leafletjs.com/reference.html#geojson-style
+ style: function(feature) { return { clickable: false, color: 'blue' }; }
+ });
+ omnivore.wkt.parse(nominatim_result.outlinestring,null,geojson_layer);
+ layerGroup.addLayer(geojson_layer);
+ map.fitBounds(geojson_layer.getBounds());
} else {
map.setView([nominatim_result.lat,nominatim_result.lon],10);
}