1. +
CREATE A LAYAR WITH DRUPAL
Tutorial
Edward Mac Gillavry
29th December 2010
2. CAVEATS
Layar module for Drupal abstracted from
homebrewed module
Only basic Layar GetPOIs-Request:
Lon,Lat,Radius, layerName
Only basic Layar GetPOIs-JSON Response:
1d objects only
Appears to be on par with Layar API version 2.1
4. PREPARE Gmap MODULE
Supports (deprecated) Google Maps API v.2
Requires API key
Log in with Google account at
http://code.google.com/apis/maps/signup.html
Fill in website URL
Click “Generate API key”
Next page provides the API key, for example:
ABQIAAAAXL4B_6HzzOGB4k4meSzVJRQAUgWGYxiuj_fVy2Vtau11dGUdwh
QWbsemrSoWUer_2wFVxZtOeFP6wA
5. CONFIGURE Gmap MODULE
Drupal: admin > settings > gmap
Fill in Google Maps API key in “Google Map
Initialize”
Configure:
Default map settings
Map type control
Click “Save configuration”
6. CONFIGURE Location MODULE
Drupal: admin > settings > location > main
Toggle location display:
Enable the display of locations
Check “Use a Google Map to set latitude and
longitude”
Click “Save configuration”
Users that are allowed to manually enter
latitude/longitude coordinates will be able to do so
with an interactive Google Map!
7. CREATE Poi CONTENT TYPE
Drupal: admin > content > types > add
Identification:
Name: Poi
Type: poi
Description: Point of Interest
Locative Information
Number of locations:
Minimum number of locations: 1
Maximum number of locations: 1
Number of locations that can be added at once: 1
Click “Save content type”.
8. CREATE Poi CONTENT
Drupal: node > add > poi
Fill in:
Name
Body
Click map to add location
Drag marker to adjust location
Click “Save”
11. CREATE Layar VIEW (3)
Fields:
Location: Latitude (decimal degrees)
Location: Longitude (decimal degrees)
Node: Title
Node: Nid
Node: Body
Filters:
Node: Published (Yes)
Node: Type (Poi)
Layar: Location latitude/longitude is within Layars requested
Proximity
12. CREATE Layar VIEW (4)
Click the gears behind “Style” in Basic settings
Feed: Style options
Layar Unique ID *: node: Nid
Layar Latitude *: node: Latitude
Layar Longitude *: node: Longitude
Layar Title *: node: Title
Layar Line 2: node_revisions: Body
Feed settings:
Path: pois
13. CREATE Layar CONTENT
Drupal: node > add > layar
Name: Pois
Layar Display View: Layar > Feed
Click “Save”
Next page provides the POI URL e.g.
http://www.yourdomain.com/layar/1
14. TEST POI URL
Open POI URL in browser
http://www.yourdomain.com/layar/1?
lang=NL&countryCode=NL&userId=93527657b34ce7f&L
on=5.11034&action=refresh&Version=4.0&Lat=52.09
62453&layerName=pois&Accuracy=252&radius=250000
For explanation of parameters, check:
http://layar.pbworks.com/w/page/28473504/GetPOI
s-Request
Adjust Lat and Lon parameters to center search
area around your POI locations
Browser returns Layar JSON-object!
15. SUGGESTIONS FOR 2011?
Add support for latest Layar API (version 4.0)
Allow content managers to adjust Layer-level
JSON response elements (e.g. Actions)
Support for Geo module (to benefit from spatial
database capabilities)
http://drupal.org.project/geo/
Investigate REST Server and Services modules
as alternatives
http://drupal.org/project/rest_server
http://drupal.org/project/services