Giter Club home page Giter Club logo

acf-address-map-field's Introduction

Advanced Custom Fields: Address/Map Field

I wanted a better map field for ACF - the native Google Map field only returns a single string for the name, which makes display and schema harder.

This field uses the same search functionality for the map, but will then populate name, phone, website, email, address (line 1/2), City, State, Zip, Country, Lat/Long, and Google Map url.

Those fields can be individually edited after the initial population from Google.

Here is the field UI:

advanced custom field address google map field

get_field() output looks like:

[name] => Space Needle
    [formatted_address] => 

										 Space Needle
										 400 Broad St
										 Seattle,
										 WA
										 98109
										 United States
										

    [address] => Array
        (
            [line_1] => 400 Broad St
            [line_2] => 
            [city] => Seattle
            [state] => WA
            [zip] => 98109
            [country] => United States
        )

    [info] => Array
        (
            [phone] => (206) 905-2100
            [website] => http://www.spaceneedle.com/
            [email] => 
            [google_map] => https://plus.google.com/103084617480514911872/about?hl=en-US
        )

    [position] => Array
        (
            [lat] => 47.620506
            [lng] => -122.34927700000003
        )

)

formatted_address is a schema markup of the address:

<div itemscope="" itemtype="http://schema.org/PostalAddress">
 <span itemprop="name">Space Needle</span>
 <span itemprop="streetAddress">400 Broad St</span>
 <span itemprop="addressLocality">Seattle</span>,
 <span itemprop="addressRegion">WA</span>
 <span itemprop="postalCode">98109</span>
 <span itemprop="addressCountry">United States</span>
</div>

WARNING: This field won't work with the_field(); - it's designed to return an array of data for a theme developer to use as they wish.

acf-address-map-field's People

Contributors

chrisgoddard avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.