Mapbox For Advanced Custom Fields

Once you’ve installed and activated the plugin…

Now all you should do is add this code to your functions.php (you can also use a plugin such as Snippets to mange this code):


function acf_mapbox_api( $api ) {
$api['key'] = 'XXXX'; // Please obtain an access token from your Mapbox account and replace the dummy value return $api;
} add_filter( 'acf/fields/mapbox/api', 'acf_mapbox_api' );

And that’s all!

If you don’t add this key to your functions.php file then you may see the following error message:

Please set the Mapbox access token and make sure to change the ACF field name.

What options are available within the Advanced Custom Fields Mapbox Field?

  1. Where the map will be centred prior to an address being entered
  2.  Map Zoom Level; the lower the number the further out the zoom
  3. Map Width (default to be 100% of the container)
  4. Map Height
  5. Mapbox a number of default Map Styles, you can select the style to best suit your needs
  6. Enable/disable 3D Maps
  7. Add a Map Marker
  8. Add a Map Popup
  9. Customise the Map Marker with your own Marker Icon
  10. Enable/disable Navigation Control (such as Zoom Level and Orientation)