• Resolved wpfan1000

    (@wpfan1000)


    Hi,
    Great plugin.
    Please consider adding eg API to eg get lat and long or all the info that Google returns in their JSON file……

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author WebFactory

    (@webfactory)

    Hi, thank you for the kind words!

    Can you please elaborate a bit on the API feature? Where would the info from JSON be displayed?

    Thread Starter wpfan1000

    (@wpfan1000)

    Hi,

    Ref:
    https://developers.google.com/maps/documentation/geocoding/intro

    My request is based on me assuming that your plugin does the following. My excuses if it does not:

    1) A user types in an address in the block’s address field.

    2) Your code does an API request to Google to get the geocoding info for this address:
    https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&key=YOUR_API_KEY

    3) You get back a JSON or XML response from Google eg:

    
    {
       "results" : [
          {
             "address_components" : [
                {
                   "long_name" : "1600",
                   "short_name" : "1600",
                   "types" : [ "street_number" ]
                },
                {
                   "long_name" : "Amphitheatre Pkwy",
                   "short_name" : "Amphitheatre Pkwy",
                   "types" : [ "route" ]
                },
                {
                   "long_name" : "Mountain View",
                   "short_name" : "Mountain View",
                   "types" : [ "locality", "political" ]
                },
                {
                   "long_name" : "Santa Clara County",
                   "short_name" : "Santa Clara County",
                   "types" : [ "administrative_area_level_2", "political" ]
                },
                {
                   "long_name" : "California",
                   "short_name" : "CA",
                   "types" : [ "administrative_area_level_1", "political" ]
                },
                {
                   "long_name" : "United States",
                   "short_name" : "US",
                   "types" : [ "country", "political" ]
                },
                {
                   "long_name" : "94043",
                   "short_name" : "94043",
                   "types" : [ "postal_code" ]
                }
             ],
             "formatted_address" : "1600 Amphitheatre Parkway, Mountain View, CA 94043, USA",
             "geometry" : {
                "location" : {
                   "lat" : 37.4224764,
                   "lng" : -122.0842499
                },
                "location_type" : "ROOFTOP",
                "viewport" : {
                   "northeast" : {
                      "lat" : 37.4238253802915,
                      "lng" : -122.0829009197085
                   },
                   "southwest" : {
                      "lat" : 37.4211274197085,
                      "lng" : -122.0855988802915
                   }
                }
             },
             "place_id" : "ChIJ2eUgeAK6j4ARbn5u_wAGqWA",
             "types" : [ "street_address" ]
          }
       ],
       "status" : "OK"
    }

    4) You take out the lat and long info to then show the map with this location in the edit and front end of the block.

    So it is my assumption that you in your code already have all the above info in memory.

    By an API I mean eg a function you write that allows developers to get parts of this info eg lat and long, full name, etc. A function I could use in a template or plugin to get the lat and long info for the current or a particular post id:

    eg:

    maps_block_get_lat (post_id);

    The reason for this is that I can then store lat and long in custom fields with the post. I can then do searches for posts located in a certain region by searching for lat and long within a range….

    This is a lot of assumption on my part though ??

    Another way of doing this would be for you to create custom fields for lat and long for each post and put the lat and long in there so it can be accessed by users…..

    Let me know your thoughts….

    • This reply was modified 6 years, 8 months ago by wpfan1000.
    Plugin Author WebFactory

    (@webfactory)

    Hi again ??

    Everything you wrote will be true in one of the upcoming versions, but at the moment it’s not ?? At the moment we’re using the simplest map integration via iframe that doesn’t require any API or geocoding. We just give it the address, and that’s it. It has barely any configuration options, but for v1 it works.

    As soon as Gutenberg takes off and people start using the plugin, we’ll switch to using the API and will be saving the data exactly as you described.

    Thread Starter wpfan1000

    (@wpfan1000)

    Thanks ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Feature request – Add ability to get lattitude, longitude, etc’ is closed to new replies.