• Hello, I have a tool (for a local history project) that imports placenames to custom posts from sources such as Wikidata. Each placename typically has lat/lon data and also an address string so what I am looking for is a way to programmatically bulk set these values using the generated post ID and, ideally, latlon figures. Can anyone give me any pointers to doing this?

    I have successfully installed the ACF OpenStreetMap Field plugin and am working on the map display.

    Thank you

Viewing 1 replies (of 1 total)
  • Thread Starter jamesinealing

    (@jamesinealing)

    I have been trying to investigate this and try a few things. Firstly, if I run acf_get_fields( 3906 ) where 3906 is the ID of the OSM ACF field in the field group, I get

        {
    "center_lat": 55,
    "center_lng": 15,
    "zoom": 15,
    "height": 400,
    "return_format": "raw",
    "allow_map_layers": 1,
    "max_markers": "",
    "layers": [

    ],
    "ID": 3909,
    "key": "field_67a416d417344",
    "label": "OSM Location",
    "name": "osmlocation",
    "aria-label": "",
    "prefix": "acf",
    "type": "open_street_map",
    "value": null,
    "menu_order": 0,
    "instructions": "",
    "required": 0,
    "id": "",
    "class": "",
    "conditional_logic": 0,
    "parent": 3906,
    "wrapper": {
    "width": "",
    "class": "",
    "id": ""
    },
    "allow_in_bindings": 1,
    "leaflet_map": "{\"lat\":53.5507112,\"lng\":10.0006485,\"zoom\":12,\"layers\":[],\"markers\":[]}",
    "_name": "osmlocation",
    "_valid": 1
    }

    If I try

    $lat='52';
    $lon="-2";
    $values = array(
    "lat" => $lat,
    "lng" => $lon
    );
    $postId = 1234; // example post of custom post type place
    $updatetGeoResult = update_field('osmlocation', $values, 'place_'.$postId);

    it returns true on first run but then false if I try it again. No obvious changes are visible in the post data after this is run (both when the post has no OSM location set, and when it does)

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.