This page last changed on Jul 06, 2006 by yecarrillo.

Drupal is a content management system (CMS) that can be used to display WMS layers from GeoServer into Drupalized websites through Google Maps API

.

Prerequisites

Drupal set-up

Download and install Drupal from here.

GMap module

  • Download the GMap module from here
  • Copy the GMap directory into the Drupal modules/ directory
  • Edit the theme template files on the themes/yourtheme/*.tpl to ensure that the html file has the following at the top of each page (the first one is recommended by Google, the second is required for the lines overlays to work in Internet Explorer:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml"></code>
  • Get a GMap API Key http://www.google.com/apis/maps/signup.html
  • Enable the 'GMap module' in Drupal settings page (admin/settings/)
  • Edit the module settings from admin/settings/gmap to include the key you've received from Google and change any other default setting.
  • Configure an 'input format' so that the GMap filter is activated. If this will be on a 'html filtered' format, ensure that the weighting is such that the HTML filter comes before the GMap filter(admin/filters/).

More detailed instructions from the README file

Creating nodes with Google Maps

Once Drupal and GMap module are configured, you can start to publish your maps by creating content (called nodes in the Drupal terminology) into your site. GMap module has two ways to insert Google Maps : GMap macro and PHP code.

GMap Macro

You can include your map somewhere into the node by using this macro syntax:

[gmap|id=map|center=49.2,-123.1|zoom=7|width=600px|height=400px|control=Small|type=Map]

GMap module includes a macro creation tool. Point your web browser to http://example.com/map/macro . Change example.com with the address of your own website. GMap author has it made publicly avaliable his macro creation tool here: http://www.webgeer.com/map/macro. Not all the features of GMap module can be included on the macro using these tools.

As of Jun 4 2006, GMap module doesn't include support for WMS layers by this method.

PHP Code

Create or edit a node(node/add/) of type page, book or story ensuring that you select PHP code as your Input Format. Use the gmap_draw_map() function. You need to prepare a parameter to this function with an array of arrays containing these values:

  • name - the name of the custom map (no spaces or special chars).
  • url - the url of the WMS service.
  • format - image format to retrieve. Depends of WMS service:
  • image/gif,'image/png','image/jpeg'
  • layers - a comma separated list of layers advertized by WMS service to show in this custom map.
  • minresolution - lowest zoom level of this custom map.
  • maxresolution - highest zoom level of this custom map.
  • copyrights - an array of copyrights to display. Each copyright array can have the following elements:
    minzoom - lowest zoom level at which this information applies.
    bounds - a comma separated list of coordinates defining a region to which this copyright information applies: 'S,W,N,E'
    text - text of the copyright message.
  • overlaywith - (optional) overlay WMS layers with this Google layers: 'Map', 'Hybrid', 'Satellite' or 'None'. Default value: 'None'
  • merczoomlevel - (optional) zoom factor of the google map where WMS service should advertize layers in Transverse Mercator projection instead of default projection. Default value: 5

Use the example below as your starting point. Just copy and paste the following code into the Body textarea.

Example

This example shows the White House using Terraserver, Lizardtech and NASA JPL WMS services (in addition to Google Map, Satellite and Hybrid maps)

Sample Screenshots
   
  Drupal map with data from Terraserver WMS service (small)
 

<?php

$north = 38.897546;
$east  = -77.039394;
$zoom  = 16;

$mywmss=array(
array('name'=>'Terraserver',
                    'url'=>'http://terraservice.net/ogcmap6.ashx?',
                    'format'=>'image/jpeg',
                    'minresolution'=>'1',
                    'maxresolution'=>'17',
                    'layers'=>'DOQ',
                    'copyrights' => array(array(
                      'minzoom'=>'1',
                      'bounds'=>'-190,-90,180,90',
                      'text'=>'&copy; terrasever',
                      )),
                    'overlaywith'=>'Hybrid',
                    'merczoomlevel'=>'5',
    ),
array('name'=>'Lizardtech',
                    'url'=>'http://wms.lizardtech.com/lizardtech/iserv/ows?service=WMS',
                    'format'=>'image/jpeg',
                    'minresolution'=>'1',
                    'maxresolution'=>'17',
                    'layers'=>'DC',
                    'copyrights' => array(array(
                      'minzoom'=>'1',
                      'bounds'=>'-190,-90,180,90',
                      'text'=>'&copy; lizardtech',
                      )),
                    'overlaywith'=>'Hybrid',
                    'merczoomlevel'=>'5',
    ),
array('name'=>'NASA_JPL',
                    'url'=>'http://wms.jpl.nasa.gov/wms.cgi?service=WMS',
                    'format'=>'image/jpeg',
                    'minresolution'=>'1',
                    'maxresolution'=>'17',
                    'layers'=>'global_mosaic',
                    'copyrights' => array(array(
                      'minzoom'=>'1',
                      'bounds'=>'-190,-90,180,90',
                      'text'=>'&copy; NASA',
                      )),
                    'overlaywith'=>'Hybrid',
                    'merczoomlevel'=>'5',
    ),
);

$mymap=array('id' => 'map',
             'control' => 'Large',
             'tcontrol' => 'on',
             'zoom' => $zoom,
             'center' => $north.','.$east,
             'width' => '100%',
             'height' => '500px',
             'type' => 'Satellite',
             'wmss' => $mywmss,
             );

echo gmap_draw_map($mymap);
?>

External Links


Document generated by Confluence on Jan 16, 2008 23:28