You are here

Using OpenLayers and GeoField to display maps in Drupal 7 (Part 2)

Development
Drupal

This is part 2 of our OpenLayers post. Take a look at part 1 for a list of the modules used and to see how to setup OpenLayers on your site and how to display a map on a node using GeoField.

We'll be using the contenttype location created in part 1.

We've used Views 7.x-3.x-dev, since Views 7.x-3.3 gave some errors (http://drupal.org/node/1444272).

The OpenLayers Data Overlay display

First we'll need to create an OpenLayers Data Overlay display in views. This is a views plugin that pulls the required data from the nodes.

It's also on this display that we'll add our filters, arguments, .. to alter the data that we want to be displayed on our map.

Create a new view without a display.

Add an OpenLayers Data Overlay display.

And add the Geo field.

Set the Format to OpenLayers Data Overlay and map the Data Source to the Geo field (WKT).

Your view settings now look like this.

Save your view.

Configure a map

Again we'll need to configure a map, like we did in part 1 for the maps on our nodes.

Go to Structure > OpenLayers > Maps (admin/structure/openlayers/maps) and add a new map. Use theBasics settings as show: You can change the width/height settings to match your layout.

Keep the default Center & Bounds settings.

Use the Layers & Styles settings as shown: 

Save your settings before continuing to the Behaviours settings.

Set the Behaviours settings like we did in Part 1, but this time select the OpenLayers Data Overlay layer as the layer to zoom to.

The display that shows the map

Make sure you only set these views settings for this display and that you don't change the default settings.

We'll return to our view and create a page display to show the map, based on the settings defined in theOpenLayers Data Overlay display.

You could also create a block if you want the block to be displayed in a block.

Set the Format to OpenLayers Map and select the OpenLayers map configuration we created above.

Now your view will show you the map.

You might get a Google Map Data overlay.
This is discussed here: http://drupal.org/node/1540534