Custom Fields
Re-Envisioned
Support Meta Box Geolocation Open Street Maps: binding of Latitude and Longitude, keeping the map in English?

  • Creator
    Topic
  • #10954
    Resolved Mauro
    Participant

    Hello Anh!
    I am migrating my back-end from Google Maps over to OMS, and I need to bind latitude and longitude of an address to meta fields. Also, the map is in the language of the region. Is there any way to force it to display names in English? It gets complicated when my location is in the UAE and all labels switch to the Arabic language… My source looks like this (I commented out “geo” to avoid loading the google maps autocomplete code)…

    Thanks for your help!
    Mauro

    $meta_boxes[] = array (
                  'title' => 'Location',
                  'post_types' =>   array (
                     'top_activity',
                     'suggested_hotel',
                     'restaurant',
                  ),
                  'context' => 'normal',
                  'priority' => 'high',
                  'status' => 'publish',
                  'autosave' => false,
                  //'geo' => true,
                  'fields' =>   array(
                    array(
                        'type' => 'text',
                        'name' => 'Address',
                        'id'    => 'address',
                    ),
                    array(
                        'type' => 'text',
                        'name' => 'Latitude',
                        'id'    => 'latitude',
                        'binding' => 'lat' // lat,lng
                    ),
                    array(
                        'type' => 'text',
                        'name' => 'Longitude',
                        'id'    => 'longitude',
                        'binding' => 'lng' // lat,lng
                    ),
                    array(
                      'id' => 'location',
                      'type' => 'osm',
                      'name' => 'Location',
                      'address_field' => 'address',
                      'language' => 'en',
                    ),
                  ),
                  'id' => 'location',
            );
Viewing 6 replies - 1 through 6 (of 6 total)
  • Author
    Replies
  • #10959
    Anh Tran
    Keymaster

    Hi Mauro,

    We’re working on the Geolocation to make it work with OSM. When it’s done, you can bind data to fields.

    Regarding the language, this is sadly the way it handles language. There’s no way to change that :(. It shows language of the current being viewed country. You can see it on its homepage https://osm.org.

    #10966
    Mauro
    Participant

    Thanks for the info Anh!… That thing about language sucks! I hope it’s not a show stopper for my client… or I’ll have to revert back to Google Maps 😮

    I found that the Location object stores latitude and longitude, so for the time being I’m relying on that to create front-end maps and serving that up through my API.

    #10969
    david.h
    Participant

    Hi Mauro and Anh,

    It is possible to display international (i.e. English) and localised (e.g. Arabic) names using OSM although it requires a custom tile server like:

    https://tile.iosb.fraunhofer.de//#map=10/30.9482/34.048/3

    Obviously MetaBox cannot provide this level of customisation, but it shows that OpenStreetMap can (and should) provide this functionality natively.

    Thanks

    #10971
    Mauro
    Participant

    Hey David, thanks for the pointer! I’m using Leaflet on the front-end — the same library used in MetaBox in my understanding. It doesn’t look like the link you posted is using Leafelet, can you point me to the providers that have this option?

    #10973
    Mauro
    Participant

    Hi David, thanks to your suggestion I was able to locate and enable an all-english tiles provider in my custom front-end implementation of Leaflet (so, no need for more pointers!)…

    I’m using the Leaflet-providers javascript extension to Leaflet to simplify providers integration and found that several tiles providers do not require an API key and have all-english labels, here are 2 of my favourites:

    Esri.WorldStreetMap
    CartoDB.Voyager

    You can check out more providers supported by the Leaflet-providers js here: https://leaflet-extras.github.io/leaflet-providers/preview/

    Anh, you may want to consider switching to one of these in a future release.

    Hope this helps!
    Mauro.

    #10994
    david.h
    Participant

    Hi Mauro,

    Glad you got it sorted – OSM/Leaflet is a really great combination.

    All the best

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