Skip to content

Comments

Country only set address on map#5

Open
loetie wants to merge 3 commits intoarjan:masterfrom
loetie:patch-1
Open

Country only set address on map#5
loetie wants to merge 3 commits intoarjan:masterfrom
loetie:patch-1

Conversation

@loetie
Copy link

@loetie loetie commented Mar 6, 2017

"Set to my entered address" does not work when only country is selected. The country field uses country codes (ex: nl,uk,de etc). The google maps api does not know how to convert those. My suggestion would be to use the text of the selected option and send that to the google maps api. This seems to work better.

"Set to my entered address" does not work when only country is selected. The country field uses country codes (ex: nl,uk,de etc). The google maps api does not know how to convert those. My suggestion would be to use the text of the selected option and send that to the google maps api. This seems to work better.
@ddeboer
Copy link
Contributor

ddeboer commented Apr 24, 2017

I cannot reproduce this problem. On the contrary, country codes work better than full names:

Code yields direct hit on the country:

curl 'http://maps.googleapis.com/maps/api/geocode/json?sensor=false&address=address_country=nl'
{
   "results" : [
      {
         "address_components" : [
            {
               "long_name" : "Netherlands",
               "short_name" : "NL",
               "types" : [ "country", "political" ]
            }
         ],

While full name yields some irrelevant addresses:

curl 'http://maps.googleapis.com/maps/api/geocode/json?sensor=false&address=address_country=Nederland'
{
   "results" : [
      {
         "address_components" : [
            {
               "long_name" : "41",
               "short_name" : "41",
               "types" : [ "street_number" ]
            },

@loetie
Copy link
Author

loetie commented Apr 24, 2017

I mentioned Google Maps Api (assumption) was used. But openstreetmap.org is used when only a country is used as parameter.

Api calls for openstreetmap:
http://nominatim.openstreetmap.org/search?format=json&limit=1&addressdetails=0&q=nl
http://nominatim.openstreetmap.org/search?format=json&limit=1&addressdetails=0&q=Nederland

The google maps api call does indeed not understand "Nederland" instead of "nl".

Should we send both parameters to mod_geo notify and pass different queries to googlemaps or openstreetmap?

@ddeboer
Copy link
Contributor

ddeboer commented Apr 24, 2017

Yes, that seems the best way; mod_geo already has access to all address parameters. Can you change this PR?

@loetie
Copy link
Author

loetie commented May 11, 2017

@ddeboer Changed the pull request so both services have their own set of parameters.

@ddeboer
Copy link
Contributor

ddeboer commented May 29, 2017

Looks good to me. @arjan Do you agree? If so, can you squash and merge this?

@ddeboer
Copy link
Contributor

ddeboer commented Jan 2, 2018

Merged this at https://github.com/zotonic/mod_geo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants