Kuvaus
A multi-point Google Maps field for Advanced Custom Fields. Click the map to add markers, drag to move them, use Remove coordinate to delete.
The plugin reads your existing Google Maps API key from ACF’s global setting (google_api_key), so no extra configuration is needed if you already use ACF Map fields. If you don’t have one set, you can also provide a key via the acfmc_gmaps_key filter.
Originally inspired by the single-point ACF: Coordinates field by Stupid Studio; this plugin extends the idea to multiple points per field.
Licensed under the GNU General Public License v3. See license.txt for details.
Usage
When you create a new custom field with ACF, set the field type to Coordinates map (under Content). The coordinates chooser will then show up when you edit a post with your custom fields.
The tool adds a point on each click on the map. To remove the point, select the ”Remove Coordinate” button and click a point. You can also show the points as a polygon on the map with the ”Show area on map” button, and show the actual coordinates in a semicolon-separated list with the ”Show coordinates” button. The search field is only there to quickly take you to different places on the map — not to add the actual points.
To get the coordinates data on your frontend, simply request the field value and you get the coordinates in a latitude/longitude array plus the zoom level, like this:
<?php
$values = get_field('*****FIELD_NAME*****');
print_r($values);
/* gives you something like:
Array
(
[coords] => Array
(
[0] => Array
(
[lat] => 57.156363766336
[lng] => 16.364327427978
)
[1] => Array
(
[lat] => 57.159612809986
[lng] => 16.370315551758
)
)
[zoom] => 13
)
*/
?>
Kuvankaappaukset


get_field() returns.
Asennus
Install this plugin by downloading the source and unzipping it into the plugin folder in your WordPress installation. Make sure to also have ACF (Advanced Custom Fields) installed and active.
UKK
-
How do I get the plugin to show a map on the website?
-
By implementing a map on your own. We do not provide a frontend implementation — that is up to you.
Arvostelut
There are no reviews for this plugin.
Avustajat & Kehittäjät
“Advanced Custom Fields: Multiple Coordinates” perustuu avoimeen lähdekoodiin. Seuraavat henkilöt ovat osallistuneet tämän lisäosan kehittämiseen.
AvustajatKäännä “Advanced Custom Fields: Multiple Coordinates” omalle kielellesi.
Oletko kiinnostunut kehitystyöstä?
Browse the code, check out the SVN repository, or subscribe to the development log by RSS.
Muutosloki
1.1.1
- The field type is now called Coordinates map in ACF’s field type browser instead of ”Multiple coordinates map”. ACF gives every field type card a fixed width and only centres labels that fit on one line, so the old label wrapped and rendered left aligned next to the centred built-in field types. Only the displayed label changed — the internal field type name (
multiple-coordinates-field) is untouched, so existing field groups and stored values keep working.
1.1.0
- Corrected the plugin description: it claimed markers were removed by right-clicking them, which the plugin has never done. Removal works the way the Usage section describes — press ”Remove coordinate”, then click the marker you want gone.
- Verified on WordPress 7.1 with ACF 6.8: the field renders, the map and its markers draw, click adds a marker, dragging moves it, ”Remove coordinate” deletes it, and the value survives save/reload unchanged. Tested up to raised to 7.1.
- Fixed: the field type did not exist on ACF 5 and ACF 6. The plugin only hooked
acf/register_fields, which is the ACF 4 API and was removed from ACF years ago. On any modern ACF the field type was never registered, so ”Multiple coordinates map” did not show up in the field type list and existing fields rendered nothing. The field type is now registered throughacf/include_field_typesas well, and the field type implementation has been ported to the ACF 5/6 field API (initialize(),render_field(),format_value(),update_value()). The ACF 4 implementation is kept for anyone still running ACF 4. - Fixed: the JavaScript never ran on ACF 5/6. Initialization used
$(document).live('acf/setup_fields')—.live()was removed in jQuery 1.9. The map now initializes on ACF’sready_field/append_fieldactions (so it also works for fields added dynamically), with a fallback for older ACF versions. - Fixed the asset URLs: they were built with the ACF 4 helper filters
acf/helpers/get_dir/acf/helpers/get_path, which no longer exist, so the CSS and JS pointed nowhere on ACF 5/6. - Fixed the zoom level not being stored when the map had no markers, and the zoom level is now saved when you zoom the map.
- Fixed a JavaScript error in ”Show area on map” (an undefined variable was passed to the polygon).
- Field values are unchanged: still the same JSON structure in the same postmeta key, so values saved with earlier versions keep working, and a malformed value is never overwritten.
- The Google Maps API key filter is renamed from
acf_multi_coords_gmaps_keytoacfmc_gmaps_key(shorter, correctly prefixed). The old name could never fire in practice, since the field type was not registered on ACF 5/6 at all.
1.0.4
- Google Maps API key — read from ACF’s global
google_api_keysetting (acf_get_setting) and aacf_multi_coords_gmaps_keyfilter, so existing ACF users get a working map out of the box. Without a key, Google Maps falls back to limited mode (watermark). - Cleaned up leftover
console.logcalls injs/map.js. - Tested up to rolled back to WordPress 7.0: the field type has not been verified working on 7.1.
1.0.3
- Plugin Check compliance: added
License/License URIheaders,ABSPATHdirect-access guard, replaced<?= ?>short echo tags with<?php echo esc_attr() ?>, added explicit version arguments towp_register_style()/wp_register_script(), switched protocol-relative Google Maps URL tohttps. - Updated Author URI to https://jonashjalmarsson.se.
- Trimmed readme tags to 5.
- Tested up to WordPress 6.9.
1.0.2
Copy feature added to copy points from one Multiple Coordinates value to another.
- Press the Copy button, right click on the selection and select Copy.
- Go to the destination Multiple Coordinates value and press the Copy button, then right click and select Paste.
- Publish or update the page or post to apply the new points.
1.0.1
- Bugfix 1. Get lat and lng from Marker via correct API function.
- Bugfix 2. ”Show area on map” button toggle now works.
- Optimized init of map when many markers.
1.0.0
- First release.
