After a couple of days bashing my head against my desk, I have finally got a C client to talk to Drupal 7.x using Services 3.x (XMLRPC) and OAuth authentication. Previously I had been using Drupal 6.x with Services 2.x and an API key, but the API key option is not available in Services 3.x. I looked for documentation explaining how to set up Services 3.x with OAuth, but I couldn't find a step-by-step tutorial. When I finally worked it out, I decided I'd better write one so that others don't have to follow my path of pain.
Please leave any comments/questions below.
Openlayers Locator is a feature module that sets up the basic functionality for a map based proximity search. It creates a content type "Location"; a view to list all these locations, a map and the search option; as well as a link to it in the main menu.
This is a screenshot of an example proximity search results.
Installing and enabling the required modules
- Install all required modules listed on the Openlayers Locator project page.
- Enable the Openlayers Proximity feature module either from the modules admin page (admin/modules) or the features admin page (admin/structure/features).
Once the feature is enabled, a new content type and the proximity search view are created and configured for you.
Create geolocated content
- Go to the 'add content' page and choose to create a new Location.
- You will find the usual title and body fields plus an address field set, fill it in and save.
- If the geolocator module was able to geolocate your address it will be shown in a map in the node page.
MapBox layer provides some baselayers, but you can add additional Mapbox layers (or Tilesets) into Openlayers yourself.
Thanks to DjebbZ for the original tutorial for D6.
Choose a Tile Set
- First, head to http://tiles.mapbox.com/mapbox in the official MapBox website.
- Choose the tileset you want to use. In this example we will assume that you want to use the World Blue tileset, but the following applies for every tileset. Note the layer name: it is the last part of the url. For the World Blue tileset, it is world-blue.
- In the right part of the page, note the information you'll need in OpenLayers : the Zoom info, specified as a range. For the World Blue tileset the zoom levels are 0-8. Some tilesets may hold a file extension but if none is specified, use png).
Create a Layer
Now go back to your Drupal installation.
- Go to
admin/structure/openlayers/layers/addfor Drupal 7 to add a new layer.
- In the list select MapBox.
- Then fill the form with the requested information:
For additional documentation, tutorials, links to presentation and upgrade information check OpenLayers 2.x Documentation for D6.
Note - D6 documentation is fairly correct except for the OpenLayers WKT field which is not present in D7. (Geofield is recommended however it has a number of critical issues)
The OpenLayers module enables the display of any content with geo data (node, user, taxonomy terms) as layers on top of base maps (base layers) in layer maps. It provides a user interface to configure the styles of this content (color of dots, thickness of lines, highlighting, ...), and the behavior of the maps (zooming, tool tips, ...).
Layers, maps, styles and behaviors are stored as objects.
The configurations can be exported to code or included as a part of a feature with the Features module.
Changes from OpenLayers 2.x for D7
- The 'Preset' were changed to maps (admin/structure/openlayers/maps).
- The OpenLayers module focuses on displaying data and therefore does not provide its own input field anymore. You can use the Geofield module for inputting geo data.
These need to be enabled before moving to the next step.Read more
By using Geofield, Geocoder, Address Field, Feeds, and Openlayers, you can create maps almost entirely from the GUI for most use cases, but at the moment Feeds can't import to Address Fields because it's dynamic. This might change in future.
Address field is useful because it gives you the proper number of fields for an address. The number and order of fields are dynamically updated when you select a country, because different countries have different address formats. Geocoder takes that address field and turns it into latitude and longitude points (“lat-longs”). Geocoder takes the lat-longs that it created and stores them in a Geofield.
Address field is great when you manually add locations, but when you want to mass import locations, you should use a regular text field and the Feeds module.
For mass importing addresses you need to create
- a Feeds importer,
- a content type with an address field and a Geofield, which will geocode the address field,
- two views: one in which to have your page display and one in which to have your open data overlay,
- and a mapping (preset) within Openlayers.