bobbingwide / oik

OIK Information Kit
https://www.oik-plugins.com/oik-plugins/oik
GNU General Public License v2.0
2 stars 0 forks source link

Set post code and other address fields as well as lat long #113

Open bobbingwide opened 5 years ago

bobbingwide commented 5 years ago

wp-content/plugins/oik/admin/oik-admin.php(673:0) oik_set_latlng(5) lat The Google Maps API does not need the post code in order to set the latitude and longitude. It can actually return the correct value. We should consider setting additional address fields if they're available. In this example, for 26, The Yews, Horndean we get

wp-content/plugins/oik/admin/oik-admin.php(674:0) oik_set_latlng(6) long 
wp-content/plugins/oik/includes/oik-remote.inc(78:0) bw_remote_get(1) 1 https://maps.google.com/maps/api/geocode/json?sensor=false&key=AIzaSyBU6GyrIrVZZ0auvDzz_x0Xl1TzbcYrPJU&address=+26+The+Yews+Horndean+Hants
wp-content/plugins/oik/includes/oik-remote.inc(78:0) bw_remote_get(2)  {
   "results" : [
      {
         "address_components" : [
            {
               "long_name" : "26",
               "short_name" : "26",
               "types" : [ "street_number" ]
            },
            {
               "long_name" : "The Yews",
               "short_name" : "The Yews",
               "types" : [ "route" ]
            },
            {
               "long_name" : "Waterlooville",
               "short_name" : "Waterlooville",
               "types" : [ "postal_town" ]
            },
            {
               "long_name" : "Hampshire",
               "short_name" : "Hampshire",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "England",
               "short_name" : "England",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "United Kingdom",
               "short_name" : "GB",
               "types" : [ "country", "political" ]
            },
            {
               "long_name" : "PO8 0BH",
               "short_name" : "PO8 0BH",
               "types" : [ "postal_code" ]
            }
         ],
         "formatted_address" : "26 The Yews, Waterlooville PO8 0BH, UK",
         "geometry" : {
            "location" : {
               "lat" : 50.9165611,
               "lng" : -0.9976893
            },
            "location_type" : "ROOFTOP",
            "viewport" : {
               "northeast" : {
                  "lat" : 50.91791008029149,
                  "lng" : -0.9963403197084979
               },
               "southwest" : {
                  "lat" : 50.91521211970849,
                  "lng" : -0.999038280291502
               }
            }
         },
         "place_id" : "ChIJR4qDgSJEdEgRNMJv8JBQOic",
         "plus_code" : {
            "compound_code" : "W282+JW Horndean, United Kingdom",
            "global_code" : "9C2XW282+JW"
         },
         "types" : [ "street_address" ]
      }
   ],
   "status" : "OK"
}
bobbingwide commented 5 years ago

When only the post code is entered then we can get quite a lot of the address, but not the house number ( street_number ).