title = $title; $this->endpoint = $endpoint; $this->layer = $layer; $this->sld = $sld; $this->transparent = true; if (!$transparency) $this->transparent = 'false'; $this->format= 'image/png'; } /** * */ function toJS($vname) { $js = "$vname = new OpenLayers.Layer.WMS('$this->title','$this->endpoint',{"; $js .= "layers: '$this->layer'"; $js .= ", format: '$this->format'"; if ($this->sld != '') $js .= ", sld: '$this->sld'"; if ($this->transparent) $js .= ", transparent:true"; else $js .= ", transparent:false"; $js .= "});\n"; return $js; } } class MapLayerWFS extends MapLayer { function MapLayerWFS($title, $endpoint, $layer, $maxfeatures) { $this->title = $title; $this->endpoint = $endpoint; $this->layer = $layer; settype($maxfeatures,'integer'); $this->maxfeatures = $maxfeatures; } function toJS($vname) { $js = "$vname = new OpenLayers.Layer.WFS('$this->title','$this->endpoint',{"; $js .= "typename: '$this->layer'"; if ($this->maxfeatures > 0) $js .= ", maxfeatures: '$this->maxfeatures'"; $js .= "}, { featureClass: OpenLayers.Feature.WFS});\n"; return $js; } } /** * Class implements a simple OpenLayers map generator. */ class MapIFrame { /** * Constructor for IFrame generator */ function MapIFrame($width, $height, $divid) { settype($width, 'string'); settype($height, 'string'); $this->width = $width; $this->height = $height; $this->divname = $divid; $this->googlebasemap = 1; //longitude latitude $this->initialPos = Array('0.0', '0.0', '2'); $this->layers = Array(); } /** * Add a Wms layer to the map */ function addWmsLayer($title, $endpoint, $layer, $sld, $transparency) { $wmslayer = new MapLayerWMS($title, $endpoint, $layer, $sld, $transparency); $this->layers[] = $wmslayer; } /** * Add a WFS layer to the map */ function addWfsLayer($title, $endpoint, $layer, $maxfeatures) { $wfslayer = new MapLayerWFS($title, $endpoint, $layer, $maxfeatures); $this->layers[] = $wfslayer; } /** * */ function toHTML() { $html = "
"; $html .= ""; $html .= ""; $html .= "\n"; $html .= ""; $html .= sprintf("Generates HTML that can be included in a web page to show a map of _whatever_. Parmeters may be specified by GET or POST. Parameters: width - The width of the IFrame (default = 800) height - The height of the IFrame (default = 475) delim - The delimiter to use for lists of values. Default is "|". Don't use "," google - Display google background. 0=none, 1=satellite, 2=plain. wms - A list of web mapping service endpoints to render (order is preserved). mlyrs - A list of layers, each entry corresponding to a wms endpoint. Note that a single wms endpoint may have more than one layer, separated by "," mtitles - A list of titles for wms layers mtrans - Transparency for each layer (use 0 or 1) sld - A list of SLDs for wms layers wfs - A list of web feature service endpoints to render (order is preserved). flyrs - A list of layers, each entry corresponding to a wfs endpoint. ftitles - A list of titles for wms layers fmaxf - A list of max number of features per layer Example: mapIFrame.php?op=map&mtitles=OpenLayers&wms=http%3A//labs.metacarta.com/wms/vmap0%3F&mlyrs=basic&mslds= mapIFrame.php?op=map&google=1 mapIFrame.php?op=map&google=1&ftitles=ds12003896&wfs=http%3A//omtest.cria.org.br%3A8080/geoserver/wfs&flyrs=ds12003896&maxfeat=500 mapIFrame.php?op=map&mtitles=meanRad&mtrans=true&wms=http%3A//omtest.cria.org.br/cgi-bin/mapserv%3Fmap%3D/opt/data/mapfiles/envlayers.map&mlyrs=meanRad&mslds= &ftitles=example_dataset&wfs=http%3A//omtest.cria.org.br%3A8080/geoserver/wfs&flyrs=example_dataset&maxfeat=500 sld: http%3A//nomad.vieglais.com/biogeosdi/backend/util/rasterDps/sldrasrc.php%3Fl%3DmeanRad%26m%3D60%26x%3D300%26n%3D6%26o%3D0.5 &mtitles=meanRad&mtrans=true&wms=http://omtest.cria.org.br/cgi-bin/ogctemp.cgi/nPUGQi&mlyrs=nPUGQi&mslds=http%3A//nomad.vieglais.com/biogeosdi/backend/util/rasterDps/sldrasrc.php%3Fl%3DnPUGQi%26m%3D0.1%26x%3D2%26n%3D6%26o%3D0.5
Example: