From: Marc Tobias Metten Date: Thu, 8 Mar 2018 15:05:43 +0000 (+0100) Subject: display of geojson works X-Git-Url: https://git.openstreetmap.org./nominatim-ui.git/commitdiff_plain/d363016e87dd121c1a0a2e01a9b057a97a6c4a5a display of geojson works --- diff --git a/TODO.md b/TODO.md index 655455a..23d30f4 100644 --- a/TODO.md +++ b/TODO.md @@ -10,13 +10,13 @@ * need /details to support &format=json * reverse: zoom not set http://localhost:8000/reverse.html?format=html&lat=52.3755991766591&lon=7.646484374999999&zoom= -* search page: add pagination, moreurl -* search page: add viewbox +* !search page: add pagination, moreurl * details page: add "There are more child objects which are not shown" back in * set acceptlanguage to API request * move this TODO.txt to github issues * write install instructions * check output of /dist into repository +* use polygon_geojson, not polygon parameter ## Unknown diff --git a/src/assets/js/base.js b/src/assets/js/base.js index d72fc79..02c228a 100644 --- a/src/assets/js/base.js +++ b/src/assets/js/base.js @@ -10,7 +10,7 @@ function get_config_value(str, default_val) { return (typeof Nominatim_Config[str] !== 'undefined' ? Nominatim_Config[str] : default_val); } -function parse_and_normalize_geojson_string(raw_string){ +function parse_and_normalize_geojson_string(part){ // normalize places the geometry into a featurecollection, similar to // https://github.com/mapbox/geojson-normalize var parsed_geojson = { @@ -18,7 +18,7 @@ function parse_and_normalize_geojson_string(raw_string){ features: [ { type: "Feature", - geometry: JSON.parse(raw_string), + geometry: part, properties: {} } ] diff --git a/src/assets/js/searchpage.js b/src/assets/js/searchpage.js index e0754dd..8df5fe0 100755 --- a/src/assets/js/searchpage.js +++ b/src/assets/js/searchpage.js @@ -153,15 +153,15 @@ function init_map_on_search_page(is_reverse_search, nominatim_results, request_l }); layerGroup.addLayer(circle); } - if (result.aBoundingBox){ + if (result.boundingbox){ - var bounds = [[result.aBoundingBox[0]*1,result.aBoundingBox[2]*1], [result.aBoundingBox[1]*1,result.aBoundingBox[3]*1]]; + var bounds = [[result.boundingbox[0]*1,result.boundingbox[2]*1], [result.boundingbox[1]*1,result.boundingbox[3]*1]]; map.fitBounds(bounds); - if (result.asgeojson && result.asgeojson.match(/(Polygon)|(Line)/) ){ + if (result.geojson && result.geojson.type.match(/(Polygon)|(Line)/) ){ var geojson_layer = L.geoJson( - parse_and_normalize_geojson_string(result.asgeojson), + parse_and_normalize_geojson_string(result.geojson), { // http://leafletjs.com/reference-1.0.3.html#path-option style: function(feature) { @@ -303,7 +303,6 @@ jQuery(document).ready(function(){ var api_request_params = { q: search_params.get('q'), polygon_geojson: search_params.get('polygon_geojson') ? 1 : 0, - polygon: search_params.get('polygon'), viewbox: search_params.get('viewbox'), format: 'jsonv2' }; diff --git a/src/templates/searchpage.hbs b/src/templates/searchpage.hbs index 479bdd4..7f574b0 100644 --- a/src/templates/searchpage.hbs +++ b/src/templates/searchpage.hbs @@ -6,7 +6,7 @@ {{/if}} {{aResult.display_name}} - {{formatLabel aResult}} + ({{formatLabel aResult}})

{{aResult.lat}},{{aResult.lon}}

details @@ -21,7 +21,7 @@
{{#if env.Search_AreaPolygons}} - + {{/if}}