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
Comment | File | Size | Author |
---|---|---|---|
#6 | Screen Shot 2018-03-21 at 9.56.22 AM.png | 93.36 KB | scottbedmonds |
#5 | Screen Shot 2018-03-21 at 9.56.44 AM.png | 79.56 KB | scottbedmonds |
Comments
Comment #2
MichelEnezy CreditAttribution: MichelEnezy commentedComment #3
scottbedmonds CreditAttribution: scottbedmonds commentedI am having the same issue. When I edit the Component Type Options for Zoom to Source, I can not set the Attach This to a Map? field. I can select, but it won't store the value.
Comment #4
m.stenta@scottbedmonds - I think the "Attach This to a Map?" option is broken (I seem to remember that it was actually removed in the dev branch, but I didn't look). In either case, you can add your component to your map by editing the Map itself, clicking on "Components" and checking the box next to your Zoom to Source component. Hope that helps!
Comment #5
scottbedmonds CreditAttribution: scottbedmonds commented@m.stenta Thank you for your reply. I have done what you mentioned. But it still does not zoom to my vector point when the map is displayed. To be clear, like the OP, I have a geofield with a lat/long widget. On Display I am selecting: Openlayers map: Openlayers Geofield: Formatter Map
Openlayers layer: openlayers_geofield_layer_formatter
Data options: Use full geometry
The map shows, but zoomed all the way out. If I change the maps default zoom, then it zooms way in to 0,0 and does not zoom to my point.
I am using 7.x-3.1+92-dev because I want to use OSM instead of broken mapquest
Thank you for any insight.
Comment #6
scottbedmonds CreditAttribution: scottbedmonds commentedSorry, adding screenshot of Components edit
Comment #7
m.stentaDid you edit the Zoom to Source component and specify the Source that you want to zoom to?
I am using Zoom to Source in the farmOS distro (http://drupal.org/project/farm). You can set up a running farmOS instance on http://simplytest.me and see how it is configured in there for comparison.
Comment #8
scottbedmonds CreditAttribution: scottbedmonds commented@m.stenta, I appreciate that. Btw, Simplytest.me is asking for a username/pass
Your tip lead me in the right direction however, I had set Zoom source correctly, but there is a check box that is set by default, in Component Type Options: Zoom just on map build is checked. Unchecking this works, and that makes sense, as it allows the zoom to happen after map build.
Thank you, and I hope this helps someone else. I would still be very interested in your FarmOS config if you don't mind allowing me in.
Thank you again
Comment #9
m.stentaHuh. Not sure why simplytest.me is requiring a username/password - might be a bug. I don't run that site - it's just a service that lets you test Drupal modules/themes/distros (gives you 30 minutes or something before the site is destroyed automatically).
You can take a look at the farmOS code for one of the zoom to source components directly here: https://github.com/farmOS/farmOS/blob/7.x-1.x/modules/farm/farm_map/farm...
Comment #10
scottbedmonds CreditAttribution: scottbedmonds commented@m.stenta Thank you!
Comment #11
ken-g CreditAttribution: ken-g as a volunteer and commentedTo summarise the above comments, to get this working you need to:
Setting issue to "Needs review".
Comment #12
ken-g CreditAttribution: ken-g as a volunteer and commented