Automatically zoom to a geofield

Created on 29 March 2017, almost 8 years ago
Updated 22 March 2023, almost 2 years ago

I use a custom content type with a Geofield field, it containt a linestring.
To display this field i use the format Openlayers Openlayers
map: Openlayers Geofield: Formatter Map
Openlayers layer: openlayers_geofield_layer_formatter
Data options: Use full geometry
The component « Openlayers Geofield: Zoom to Source » is enable and attach at this map

$ol_component = new stdClass();
$ol_component->disabled = FALSE; /* Edit this to true to make a default ol_component disabled initially */
$ol_component->api_version = 1;
$ol_component->machine_name = 'openlayers_geofield_component_zoom_to_source';
$ol_component->name = 'Openlayers Geofield: Zoom to Source';
$ol_component->description = '';
$ol_component->factory_service = 'openlayers.Component:ZoomToSource';
$ol_component->options = array(
'source' => array(
'openlayers_geofield_source_vector' => 'openlayers_geofield_source_vector',
),
'animations' => array(
'pan' => 500,
'zoom' => 500,
),
'zoom' => 'auto',
'enableAnimations' => 1,
'process_once' => 1,
'max_zoom' => 0,
);

But the view shows the map with the position and zoom defined in the map setting.
If move and zoom manualy the map to the location of my geofield it’s ok i can see it.

Is « Openlayers Geofield: Zoom to Source » the right way to get a map center on the geofield

💬 Support request
Status

Needs review

Version

3.0

Component

OL API

Created by

🇫🇷France MichelEnezy

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇬🇧United Kingdom ken-g

    To summarise the above comments, to get this working you need to:

    • create new new component "Zoom to Source"
    • ensure the correct source is specified in the component type options screen
    • add the new component to the required map (this wasn't working properly, but was fixed in 7.x-3.2)

    Setting issue to "Needs review".

Production build 0.71.5 2024