User Tools

Site Tools


tecnica:gps_cartografia_gis:php_mapscript_recipes

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
tecnica:gps_cartografia_gis:php_mapscript_recipes [2010/01/29 21:18] niccolotecnica:gps_cartografia_gis:php_mapscript_recipes [2010/02/26 19:28] niccolo
Line 74: Line 74:
  
 For inline images you can omit web paths, because no temporary images will be created. For inline images you can omit web paths, because no temporary images will be created.
 +
 +===== Make a query =====
 +
 +Open an existing map file and perform a query-by-rectangle on a layer.
 +
 +<code php>
 +<?php
 +
 +$map = ms_newMapObj("/var/www/demo.map");
 +
 +$selrect = ms_newrectObj();
 +$selrect->setextent(1681023, 4850413, 1681906, 4851167);
 +$map->queryByRect($selrect);
 +$buffer = $map->processquerytemplate(array(), false);
 +
 +print "<table border=\"1\">\n";
 +print $buffer;
 +print "</table>\n";
 +?>
 +</code>
 +
 +The **''$buffer''** variable contains one template instance for each record.
 +
 +The querable layer is definend in the ''**MAP.LAYER**'' section, and it requires a query template:
 +
 +<file>
 +MAP
 +  ...
 +  LAYER
 +    ...
 +    TEMPLATE "query_template.html"
 +    TOLERANCE 6
 +    METADATA
 +      DESCRIPTION    "Impianti Pubblicitari"
 +      RESULT_FIELDS  "objectid,field1,field2"
 +      RESULT_HEADERS "ID,Heading1,Heading2"
 +    END
 +  END
 +END
 +</file>
 +
 +This is an example for **''query_template.html''**:
 +
 +<code html>
 +<!-- MapServer Template -->
 +<tr><td>[item name=objectid]</td><td>[item name=field1]</td><td>[item name=field2]</td></tr>
 +</code>
tecnica/gps_cartografia_gis/php_mapscript_recipes.txt · Last modified: 2010/02/26 23:46 by niccolo