OpenStreetMaps auto fill selects county field for the city and saves it as city
This topic contains 12 replies, has 4 voices, and was last updated by directoryfan 4 years, 9 months ago.
We have moved to a support ticketing system and our forums are now closed.
Open Support TicketTagged: address auto fill german, snippet
-
AuthorPosts
-
January 27, 2020 at 2:30 pm #527515
Hello Support Team,
the auto fill for the address and city does not work properly after update to v2. It chooses address.county instead address.city or address.village from the OSM-API response.
In my opinion it should fill the listing form fields just with values like:
Listing Address Field: address.road address.house_number, address.village (if there is an address.city or address.town, otherwise no village)
Listing City/Location Field: address.city|town|villageFor Example:
searching for: ‘Messingstraße 10, Legelshurst′
OSM will suggest the address: ’10, Messingstraße, Willstätt, Ortenaukreis,…’
and the autofill for address: ’10, Messingstraße’
it should be:’Messingstraße 10’
can be: ‘Messingstraße 10, Willstätt’
and the autofill value for the City field: ‘Ortenaukreis′
it should be: ‘Willstätt′ not the county, this is no city.I had problems with this in v1 too and Stiofan has managed this with an overwrite for my site, see here please:
and here:
Now after the update to v2, the address.county is saved as location and this is a bug or is related to the changes of Stiofan in the v1.
1. How can I change the auto fill to set the right value for the city field on the Add listing form? (address.city or address.village instead of address.county)
2. How can I change the auto fill for the address field. I want to have it in the German format: address.road address.house_number, address.village (but just if there is an address.city too, otherwise I’ll have the location twice, in the address field and in the city field)
January 27, 2020 at 2:32 pm #527516This reply has been marked as private.January 27, 2020 at 7:23 pm #527555The developers will check into it.
January 28, 2020 at 2:39 pm #527725Hi directoryfan,
Could you please share FTP details in private reply.
Thanks
January 28, 2020 at 3:48 pm #527736This reply has been marked as private.January 28, 2020 at 3:49 pm #527737Thank you Naveen for looking into it!
January 30, 2020 at 9:37 am #528009Hi @directoryfan,
Use following PHP snippet to adjust city for addresses within Germany.
/** * Adjust city for Germany addresses with OSM. */ function gd_snippet_adjust_geocode_city() { ?> if ( window.gdMaps == 'osm' ) { if ( getCountryISO == 'DE' && response.address ) { gdaddr = response.address; if ( ! gdaddr.city && ! gdaddr.town && gdaddr.village ) { getCity = gdaddr.village; response.city = getCity; } } } <?php } add_filter( 'geodir_add_listing_geocode_js_vars', 'gd_snippet_adjust_geocode_city', 30 );
I have added snippet under Snippets > OpenStreetMap autocomplete search adjust city.
Please check and let us know.
Regards,
KiranJanuary 30, 2020 at 11:33 am #528018Hi @kiranprajapati,
and thank you Kiran for your great help! The city field is saving now the right data.
1. You have some php tags in the snippet, is this OK? I have no error in the backend, it is just unusual.
2. How can I change the address format of the address field, not the city field. Now I have 5 Street – but the German is Street 5, so first is the street and then the street number.
Thank you so much for your help!
MariusJanuary 30, 2020 at 12:18 pm #5280251) It is required.
2) It fill address what it get from the OpenStreetMaps address search response. https://nominatim.openstreetmap.org/search?q=Messingstra%C3%9Fe%2010,%20Legelshurst&format=json&addressdetails=1&limit=1&accept-language=en
Kiran
February 12, 2020 at 11:01 am #529948Hi @kiranprajapati,
and thank you for your help! I’ll try to be more clear about the problem with the German address format for OSM.1. Address format for Germany
Yes, the response is O.K., it is like it should be.
[ { "place_id": 169981210, "licence": "Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright", "osm_type": "way", "osm_id": 352879183, "boundingbox": [ "48.5723478", "48.5724337", "7.9127649", "7.9129952" ], "lat": "48.57238835", "lon": "7.912879965448619", "display_name": "10, Messingstraße, Willstätt, Ortenaukreis, Baden-Württemberg, 77731, Deutschland", "class": "building", "type": "yes", "importance": 0.22100000000000003, "address": { "house_number": "10", "road": "Messingstraße", "village": "Willstätt", "county": "Ortenaukreis", "state": "Baden-Württemberg", "postcode": "77731", "country": "Deutschland", "country_code": "de" } } ]
Just that the house number starts the string in the field display_name. But in Germany the house number is after the street name, so how can you change this?
This is how it should be, after choosing the autocomplete address string:
address.road address.house_number, address.village
like in the Nominatin docs: de street_name {street} {house_number} (https://wiki.openstreetmap.org/wiki/Nominatim/Country_Address_Format)
2. Search restriction and optimization
Please take a look at the Nominatin API and params: https://nominatim.org/release-docs/develop/api/Search/
In order to restrict and optimize the search and the country address format (feature request: could be super cool to have these options in the back-end)
As my project is restricted to one German state how should I use these params for the search query?:
accept-language='de' countrycodes='de' viewbox=7.5,47.6,10.5,49.8 bounded=1
Please help me, this will be great for different countries, since different countries have different address formats.
Greetings, Marius
February 12, 2020 at 7:09 pm #530026At this time we do not have per-country address formatting. Instead the address field uses a common format. What you are asking for currently requires a customization, but we do plan on looking into this for future versions.
February 13, 2020 at 4:43 am #530077Hi @directoryfan,
I have opened a task to check it feasible to use address format for different countries.
See https://github.com/AyeCode/geodirectory/issues/1063
Kiran
March 3, 2020 at 11:34 pm #533399Hi @kiranprajapati,
and thank your for your attention and for looking into the address format issue.I think the issue with the search restriction and optimization is important for local directories. If someone is searching for a very popular address, then the response from Nominatin API will often not include it in the proposals for automatic completion. Even addresses from other countries are proposed.
Please take a look at the Nominatin API and params: https://nominatim.org/release-docs/develop/api/Search/
As my project is restricted to one German state how should I use these params for the search query?:
accept-language='de' countrycodes='de' viewbox=7.5,47.6,10.5,49.8 bounded=1
to have something like this:
The JS code is here:
https://github.com/AyeCode/geodirectory/blob/master/assets/leaflet/osm.geocode.js
And Stiofan changed it for me in v1. It will be perfect if you could add some backend settings for the advanced search like: countrycodes, viewbox and bounded. Like that, the Nominatin API will respond much faster and the user can use the proposals in case of popular street names in that country or language.
Please add this as feature request to github or please help me to to customize the osm.geocode.js.
Greetings
-
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket