Home > GIS > MapServer: Using Google Maps with PHP MapScript

MapServer: Using Google Maps with PHP MapScript

February 12th, 2009 Rahul Leave a comment Go to comments

Generating Google Maps tiles using MapServer is not completely intuitive. For static map applications, a new tile mode has recently been created for MapServer CGI mode ( http://mapserver.org/output/tile_mode.html ).

For more dynamic mapping applications, PHP MapScript is an ideal way execute this, as it only requires a very small static component (an initial map file, which won’t even be needed when MapServer 5.4 comes). Included is a short PHP example on how do go about doing this. The PROJ.4 projection parameters included are for the Google Maps mercator projection.

The sample code includes WGS84 to Google Maps mercator projection as well as the calculation of mercator extents from Google Maps tile indices.

This example has been extended from the previous iteration to include dynamic layer generation and POINT geometry feature symbols via image files. The $phplayers variable holds layer definitions that have been queried from a database table, obtained using the getLayersForSessionID($sessionID) function. The table includes layer table name, layer geometrytype layer geometry name, and a symbol definition for the layer. For point layers, this is an image file (ie. “image.gif”), and for polygon and line layers, this is a line color (255 0 0 for red).

Attached Files:

VN:F [1.9.2_1090]
Rating: 5.0/5 (2 votes cast)
VN:F [1.9.2_1090]
Rating: +1 (from 1 vote)
MapServer: Using Google Maps with PHP MapScript, 5.0 out of 5 based on 2 ratings
Categories: GIS Tags: , , , , , , , ,
  1. Patricio
    April 9th, 2009 at 13:17 | #1

    Puedes poner un ejemplo funcionando a cerca del tema que describiste y si no fuera mucha la molestia el codigo fuente completo. Gracias Saludos.

    VA:F [1.9.2_1090]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.2_1090]
    Rating: 0 (from 0 votes)
  2. Varun
    April 30th, 2009 at 13:12 | #2

    I am new to PHP and also Mapserver. I have successfully drawn a layer on google maps using a map file. However, its a static map right now. How can I get information from mapserver when I click on the google map on a selected area?

    VA:F [1.9.2_1090]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.2_1090]
    Rating: 0 (from 0 votes)
  3. June 10th, 2009 at 23:03 | #3

    Hello, can you attach include.php too? :)

    thx

    VA:F [1.9.2_1090]
    Rating: 3.0/5 (1 vote cast)
    VA:F [1.9.2_1090]
    Rating: 0 (from 0 votes)
  4. yudi
    October 11th, 2009 at 06:11 | #4

    can you explain of include.php
    thanks

    VA:F [1.9.2_1090]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.2_1090]
    Rating: 0 (from 0 votes)
  5. Venkat
    January 10th, 2010 at 23:46 | #5

    Hi,

    How good about UNM Mapserver(Mapscript API) and Google maps API. Which is the best..

    Thanks and Regards,

    Venkat

    VA:F [1.9.2_1090]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.2_1090]
    Rating: 0 (from 0 votes)
  6. July 6th, 2010 at 21:05 | #6

    Where is include.php file

    VA:F [1.9.2_1090]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.2_1090]
    Rating: 0 (from 0 votes)
  1. No trackbacks yet.