[fusion-commits] r1845 - in trunk/widgets: . FeatureInfo
FeatureInfo/classes
svn_fusion at osgeo.org
svn_fusion at osgeo.org
Thu Apr 30 17:22:49 EDT 2009
Author: pagameba
Date: 2009-04-30 17:22:49 -0400 (Thu, 30 Apr 2009)
New Revision: 1845
Added:
trunk/widgets/FeatureInfo.js
trunk/widgets/FeatureInfo/
trunk/widgets/FeatureInfo/classes/
trunk/widgets/FeatureInfo/classes/feature.php
trunk/widgets/FeatureInfo/classes/featureinfo.php
trunk/widgets/FeatureInfo/classes/property.php
trunk/widgets/FeatureInfo/featureinfocontroller.php
trunk/widgets/FeatureInfo/featureinfomain.php
Log:
re #248, adding new Feature Info widget that displays the total area of selected features for now, but could be extended to compute other values in the future.
Added: trunk/widgets/FeatureInfo/classes/feature.php
===================================================================
--- trunk/widgets/FeatureInfo/classes/feature.php (rev 0)
+++ trunk/widgets/FeatureInfo/classes/feature.php 2009-04-30 21:22:49 UTC (rev 1845)
@@ -0,0 +1,36 @@
+<?php
+
+//
+// Copyright (C) 2004-2006 Autodesk, Inc.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of version 2.1 of the GNU Lesser
+// General Public License as published by the Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+//
+
+class Feature
+{
+ public $displayValue = '';
+ public $centerX = '';
+ public $centerY = '';
+ public $idList = null;
+
+ function __construct($displayValue, $centerPoint, $idList)
+ {
+ $this->displayValue = $displayValue;
+ $this->centerX = $centerPoint->GetCoordinate()->GetX();
+ $this->centerY = $centerPoint->GetCoordinate()->GetY();
+ $this->idList = $idList;
+ }
+}
+
+?>
\ No newline at end of file
Property changes on: trunk/widgets/FeatureInfo/classes/feature.php
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/widgets/FeatureInfo/classes/featureinfo.php
===================================================================
--- trunk/widgets/FeatureInfo/classes/featureinfo.php (rev 0)
+++ trunk/widgets/FeatureInfo/classes/featureinfo.php 2009-04-30 21:22:49 UTC (rev 1845)
@@ -0,0 +1,67 @@
+<?php
+
+//
+// Copyright (C) 2004-2006 Autodesk, Inc.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of version 2.1 of the GNU Lesser
+// General Public License as published by the Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+//
+
+require_once('property.php');
+require_once('feature.php');
+
+class FeatureInfo
+{
+ private $args = null;
+ private $site = null;
+
+ function __construct($args)
+ {
+ $this->args = $args;
+ $this->site = new MgSiteConnection();
+ $this->site->Open(new MgUserInformation($args['SESSION']));
+ }
+
+ function GetMapLayerNames()
+ {
+ $layerNames = array();
+
+ $resourceService = $this->site->CreateService(MgServiceType::ResourceService);
+
+ $map = new MgMap();
+ $map->Open($resourceService, $this->args['MAPNAME']);
+ $layers = $map->GetLayers();
+
+ for ($i = 0; $i < $layers->GetCount(); $i++)
+ {
+ $layer = $layers->GetItem($i);
+
+ //TODO: Exclude Raster and Drawing Layers???
+
+ if((substr($layer->GetName(), 0, 1) != "_") && (substr(strtoupper($layer->GetFeatureSourceId()), 0, 7) != "SESSION"))
+ {
+ $layerNames[$layer->GetName()] = $layer->GetLegendLabel();
+ }
+ }
+ asort($layerNames);
+
+ return $layerNames;
+ }
+
+ function SelectFeatures() {
+
+ }
+
+
+}
+?>
\ No newline at end of file
Property changes on: trunk/widgets/FeatureInfo/classes/featureinfo.php
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/widgets/FeatureInfo/classes/property.php
===================================================================
--- trunk/widgets/FeatureInfo/classes/property.php (rev 0)
+++ trunk/widgets/FeatureInfo/classes/property.php 2009-04-30 21:22:49 UTC (rev 1845)
@@ -0,0 +1,32 @@
+<?php
+
+//
+// Copyright (C) 2004-2006 Autodesk, Inc.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of version 2.1 of the GNU Lesser
+// General Public License as published by the Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+//
+
+class Property
+{
+ public $name = '';
+ public $isString = false;
+
+ function __construct($name, $isString)
+ {
+ $this->name = $name;
+ $this->isString = $isString;
+ }
+}
+
+?>
\ No newline at end of file
Property changes on: trunk/widgets/FeatureInfo/classes/property.php
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/widgets/FeatureInfo/featureinfocontroller.php
===================================================================
--- trunk/widgets/FeatureInfo/featureinfocontroller.php (rev 0)
+++ trunk/widgets/FeatureInfo/featureinfocontroller.php 2009-04-30 21:22:49 UTC (rev 1845)
@@ -0,0 +1,105 @@
+<?php
+
+//
+// Copyright (C) 2004-2006 Autodesk, Inc.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of version 2.1 of the GNU Lesser
+// General Public License as published by the Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+//
+
+ $fusionMGpath = '../../layers/MapGuide/php/';
+ require_once $fusionMGpath . 'Common.php';
+ require_once $fusionMGpath . 'Utilities.php';
+ require_once $fusionMGpath . 'JSON.php';
+ require_once 'classes/featureinfo.php';
+
+ $args = ($_SERVER['REQUEST_METHOD'] == "POST") ? $_POST : $_GET;
+
+ try {
+ $responseType = 'text/plain';
+ $response = '';
+
+ $site = new MgSiteConnection();
+ $site->Open(new MgUserInformation($args['SESSION']));
+
+ $resourceService = $site->CreateService(MgServiceType::ResourceService);
+ $featureService =
+ $site->CreateService(MgServiceType::FeatureService);
+
+ $layerName = $args['LAYERNAME'];
+ $mapName = $args['MAPNAME'];
+ $map = new MgMap($site);
+ $map->Open($mapName);
+
+ $layer = $map->GetLayers()->GetItem($layerName);
+ $className = $layer->GetFeatureClassName();
+
+ $selection = new MgSelection($map);
+ $selection->Open($resourceService, $mapName);
+
+ $properties = NULL;
+
+ if ($selection->Contains($layer, $className)) {
+ $featureReader = $selection->GetSelectedFeatures($layer, $className, new MgStringCollection());
+
+ /* Get the map SRS - we use this to convert distances */
+ $srsFactory = new MgCoordinateSystemFactory();
+ //safely get an SRS ... (in Utilities)
+ $srsDefMap = GetMapSRS($map);
+ $srsMap = $srsFactory->Create($srsDefMap);
+ $featureResId = new MgResourceIdentifier($layer->GetFeatureSourceId());
+
+ $spatialContext = $featureService->GetSpatialContexts($featureResId, true);
+ $srsLayerWkt = false;
+ if($spatialContext != null && $spatialContext->ReadNext() != null) {
+ $srsLayerWkt = $spatialContext->GetCoordinateSystemWkt();
+ /* skip this layer if the srs is empty */
+ }
+ if ($srsLayerWkt == null) {
+ $srsLayerWkt = $srsDefMap;
+ }
+ /* create a coordinate system from the layer's SRS wkt */
+ $srsLayer = $srsFactory->Create($srsLayerWkt);
+
+ // exclude layer if:
+ // the map is non-arbitrary and the layer is arbitrary or vice-versa
+ // or
+ // layer and map are both arbitrary but have different units
+ //
+ $bLayerSrsIsArbitrary = ($srsLayer->GetType() == MgCoordinateSystemType::Arbitrary);
+ $bMapSrsIsArbitrary = ($srsMap->GetType() == MgCoordinateSystemType::Arbitrary);
+
+ $bNeedsTransform = false;
+ if (($bLayerSrsIsArbitrary != $bMapSrsIsArbitrary) ||
+ ($bLayerSrsIsArbitrary && ($srsLayer->GetUnits() != $srsMap->GetUnits()))) {
+ $bComputedProperties = false;
+ } else {
+ $srsTarget = null;
+ $srsXform = null;
+ $bNeedsTransform = ($srsLayer->GetUnitScale() != 1.0);
+ }
+ $properties = BuildSelectionArray($featureReader, $layerName, $properties, true, $srsLayer, $bNeedsTransform, $layer);
+
+ }
+
+ $response = json_encode($properties);
+
+ } catch (MgException $e) {
+ echo "ERROR: " . $e->GetMessage() . "\n";
+ echo $e->GetDetails() . "\n";
+ echo $e->GetStackTrace() . "\n";
+ }
+
+ header('Content-Type: ' . $responseType);
+ echo trim($response);
+?>
\ No newline at end of file
Property changes on: trunk/widgets/FeatureInfo/featureinfocontroller.php
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/widgets/FeatureInfo/featureinfomain.php
===================================================================
--- trunk/widgets/FeatureInfo/featureinfomain.php (rev 0)
+++ trunk/widgets/FeatureInfo/featureinfomain.php 2009-04-30 21:22:49 UTC (rev 1845)
@@ -0,0 +1,298 @@
+<?php
+
+//
+// Copyright (C) 2004-2006 Autodesk, Inc.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of version 2.1 of the GNU Lesser
+// General Public License as published by the Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+//
+
+ $fusionMGpath = '../../layers/MapGuide/php/';
+ require_once $fusionMGpath . 'Common.php';
+ require_once $fusionMGpath . 'Utilities.php';
+ require_once $fusionMGpath . '/JSON.php';
+ require_once 'classes/featureinfo.php';
+
+ $args = ($_SERVER['REQUEST_METHOD'] == "POST") ? $_POST : $_GET;
+
+ $errorMsg = null;
+ $errorDetail = null;
+
+ try
+ {
+ $featureInfo = new FeatureInfo($args);
+
+ $layerNames = $featureInfo->GetMapLayerNames();
+ }
+ catch (MgException $mge)
+ {
+ $errorMsg = $mge->GetMessage();
+ $errorDetail = $mge->GetDetails();
+ echo $errorMsg;
+ echo $errorDetail;
+ }
+ catch (Exception $e)
+ {
+ $errorMsg = $e->GetMessage();
+ echo $errorMsg;
+ }
+?>
+<html>
+<head>
+ <title>Feature Information</title>
+ <link rel="stylesheet" href="../../common/mgsamples.css" type="text/css">
+ <script language="javascript" src="../../common/browserdetect.js"></script>
+ <script language="javascript" src="../../common/json.js"></script>
+ <script language="javascript" src="../../layers/MapGuide/MapGuideViewerApi.js"></script>
+
+ <script language="javascript">
+
+ var READY_STATE_UNINITIALIZED = 0;
+ var READY_STATE_LOADING = 1;
+ var READY_STATE_LOADED = 2;
+ var READY_STATE_INTERACTIVE = 3;
+ var READY_STATE_COMPLETE = 4;
+
+ var NOT_BUSY_IMAGE = "../../common/images/loader_inactive.gif";
+ var BUSY_IMAGE = "../../common/images/loader_pulse.gif";
+
+ var session = '<?= $args['SESSION'] ?>';
+ var mapName = '<?= $args['MAPNAME'] ?>';
+
+ var properties = null;
+ var results;
+
+ var reqHandler;
+
+ function OnLayerChange() {
+ var map = GetFusionMapWidget();
+ map.clearSelection();
+ var layerSelect = document.getElementById('layerSelect');
+ var layer = map.layerRoot.findLayerByAttribute('layerName', layerSelect.value);
+ map.setActiveLayer(layer);
+ }
+
+ function ActiveLayerChange(evt, layer) {
+ var layerSelect = document.getElementById('layerSelect');
+ for (var i=0; i<layerSelect.options.length; i++) {
+ if (layerSelect.options[i].value == layer.layerName) {
+ layerSelect.options[i].selected = true;
+ }
+ }
+ var map = GetFusionMapWidget();
+ map.clearSelection();
+ }
+
+ function OnDigitizePoint() {
+ DigitizePoint(OnPointDigitized);
+ }
+
+ function OnPointDigitized(point) {
+ var tolerance = GetFusionMapWidget().pixToGeoMeasure(3);
+ var min = {x:point.X-tolerance,y:point.Y-tolerance};
+ var max = {x:point.X+tolerance,y:point.Y+tolerance};
+ var geom = 'POLYGON(('+ min.x + ' ' + min.y + ', ' + max.x + ' ' + min.y + ', ' + max.x + ' ' + max.y + ', ' + min.x + ' ' + max.y + ', ' + min.x + ' ' + min.y + '))';
+
+ SetSpatialFilter(geom);
+ }
+ function OnDigitizeRectangle() {
+ DigitizeRectangle(OnRectangleDigitized);
+ }
+
+ function OnRectangleDigitized(rectangle) {
+ var min = rectangle.Point1;
+ var max = rectangle.Point2;
+ var geom = 'POLYGON(('+ min.X + ' ' + min.Y + ', ' + max.X + ' ' + min.Y + ', ' + max.X + ' ' + max.Y + ', ' + min.X + ' ' + max.Y + ', ' + min.X + ' ' + min.Y + '))';
+
+ SetSpatialFilter(geom);
+ }
+
+ function OnDigitizePolygon() {
+ DigitizePolygon(OnPolyonDigitized);
+ }
+
+ function OnPolyonDigitized(polygon) {
+ var points = [];
+ for (var i = 0; i < polygon.Count; i++) {
+ points.push(polygon.Point(i).X+' '+polygon.Point(i).Y);
+ }
+ var geomText = 'POLYGON(('+points.join(',')+'))';
+ SetSpatialFilter(geomText);
+ }
+
+ function SetSpatialFilter(geomText) {
+ ClearDigitization();
+ var options = {};
+ options.selectionType = 'INTERSECTS';
+ options.maxFeatures = 0;
+ options.geometry = geomText;
+ var layerSelect = document.getElementById("layerSelect");
+ options.layers = layerSelect.value;
+
+ GetFusionMapWidget().query(options);
+ }
+
+ function SelectionOn() {
+ var layerSelect = document.getElementById("layerSelect");
+ var reqParams = "SESSION=" + encodeURIComponent(session);
+ reqParams += "&MAPNAME=" + encodeURIComponent(mapName);
+ reqParams += "&LAYERNAME=" + encodeURIComponent(layerSelect.value);
+
+ if (msie)
+ reqHandler = new ActiveXObject("Microsoft.XMLHTTP");
+ else
+ reqHandler = new XMLHttpRequest();
+
+ reqHandler.onreadystatechange = OnReadyStateChange;
+ reqHandler.open("POST", "featureinfocontroller.php", true);
+ reqHandler.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
+
+ document.getElementById('totalFeatures').innerHTML = 'fetching feature info ...';
+ document.getElementById('totalArea').innerHTML = ''
+ document.getElementById("layerSelect").disabled = true;
+ document.getElementById("pointButton").disabled = true;
+ document.getElementById("rectButton").disabled = true;
+ document.getElementById("polyButtton").disabled = true;
+ document.getElementById("busyImg").src = BUSY_IMAGE;
+
+ reqHandler.send(reqParams);
+ }
+
+ function OnReadyStateChange()
+ {
+ var ready = reqHandler.readyState;
+
+ if (ready == READY_STATE_COMPLETE)
+ {
+ var results = reqHandler.responseText.parseJSON();
+ if (results) {
+ var layerSelect = document.getElementById('layerSelect');
+
+ var layerInfo = results[layerSelect.value];
+ if (layerInfo) {
+ var areaIdx;
+ for (var i=0; i<layerInfo.metadatanames.length; i++) {
+ if (layerInfo.metadatanames[i] == 'area') {
+ areaIdx = i;
+ break;
+ }
+ }
+ if (typeof areaIdx != 'undefined') {
+ var totalArea = 0;
+ var n = layerInfo.numelements;
+ for (var i=0; i<n; i++) {
+ var metadata = layerInfo.metadata[i];
+ totalArea += metadata[areaIdx];
+ }
+ document.getElementById('totalFeatures').innerHTML = n + ' features selected';
+ document.getElementById('totalArea').innerHTML = 'Area: ' + totalArea + ' m<sup>2</sup>';
+ } else {
+ document.getElementById('totalArea').innerHTML = 'areaIdx undefined';
+ }
+ } else {
+ document.getElementById('totalArea').innerHTML = 'no layer info';
+ }
+ } else {
+ document.getElementById('totalFeatures').innerHTML = 'no features in selected layer.';
+ }
+
+
+ document.getElementById("layerSelect").disabled = false;
+ document.getElementById("pointButton").disabled = false;
+ document.getElementById("rectButton").disabled = false;
+ document.getElementById("polyButtton").disabled = false;
+ document.getElementById("busyImg").src = NOT_BUSY_IMAGE;
+ reqHandler = null;
+ }
+ }
+ function SelectionOff() {
+ document.getElementById('totalFeatures').innerHTML = 'no features selected.';
+ document.getElementById('totalArea').innerHTML = '';
+ }
+
+ function OnLoad() {
+ var map = GetFusionMapWidget();
+ map.registerForEvent(Fusion.Event.MAP_SELECTION_ON, SelectionOn);
+ map.registerForEvent(Fusion.Event.MAP_SELECTION_OFF, SelectionOff);
+ map.registerForEvent(Fusion.Event.MAP_ACTIVE_LAYER_CHANGED, ActiveLayerChange);
+ var layer = map.getActiveLayer();
+ if (layer) {
+ ActiveLayerChange(null, layer);
+ }
+ OnLayerChange();
+ }
+
+ function OnUnload() {
+ var map = GetFusionMapWidget();
+ map.deregisterForEvent(Fusion.Event.MAP_SELECTION_ON, SelectionOn);
+ map.deregisterForEvent(Fusion.Event.MAP_SELECTION_OFF, SelectionOff);
+ map.deregisterForEvent(Fusion.Event.MAP_ACTIVE_LAYER_CHANGED, ActiveLayerChange);
+ }
+
+ </script>
+
+</head>
+
+<body onLoad="OnLoad();" onUnload="OnUnload();" marginwidth=5 marginheight=5 leftmargin=5 topmargin=5 bottommargin=5 rightmargin=5>
+
+<?php if ($errorMsg == null) { ?>
+
+<table class="RegText" border="0" cellspacing="0" width="100%">
+ <tr><td class="Title"><img id="busyImg" src="../../common/images/loader_inactive.gif" style="vertical-align:bottom"> Feature Information<hr></td></tr>
+ <tr><td class="SubTitle">Select a Layer</td></tr>
+ <tr><td>Layer:</td></tr>
+ <tr>
+ <td class="RegText">
+ <select size="1" class="Ctrl" id="layerSelect" onChange="OnLayerChange()" style="width: 100%">
+ <?php
+ $selected = 'selected';
+ foreach($layerNames as $layerName => $layerLabel) {
+ ?>
+ <option value="<?= $layerName ?>" <?=$selected ?> ><?= $layerLabel ?></option>
+ <?php
+ $selected = '';
+ }
+ ?>
+ </select>
+ </td>
+ </tr>
+ <tr><td class="Spacer"></td></tr>
+
+ <tr><td class="SubTitle">Select Features:</td></tr>
+ <tr><td>Digitize:</td></tr>
+ <tr>
+ <td align="center">
+ <input type="button" name="" value="Point" class="Ctrl" id="pointButton" onClick="OnDigitizePoint()" style="width: 30%">
+ <input type="button" name="" value="Rectangle" class="Ctrl" id="rectButton" onClick="OnDigitizeRectangle()" style="width: 30%">
+ <input type="button" name="" value="Polygon" class="Ctrl" id="polyButtton" onClick="OnDigitizePolygon()" style="width: 30%">
+ </td>
+ </tr>
+ <tr><td class="Spacer"></td></tr>
+ <tr><td class="SubTitle">Total:</td></tr>
+ <tr><td id="totalFeatures">no features selected.</td></tr>
+ <tr><td id="totalArea"></td></tr>
+</table>
+
+<?php } else { ?>
+
+<table class="RegText" border="0" cellspacing="0" width="100%%">
+ <tr><td class="Title">Error<hr></td></tr>
+ <tr><td><?= $errorMsg ?></td></tr>
+ <tr><td><?= $errorDetail ?></td></tr>
+</table>
+
+<?php } ?>
+
+</body>
+
+</html>
Property changes on: trunk/widgets/FeatureInfo/featureinfomain.php
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/widgets/FeatureInfo.js
===================================================================
--- trunk/widgets/FeatureInfo.js (rev 0)
+++ trunk/widgets/FeatureInfo.js 2009-04-30 21:22:49 UTC (rev 1845)
@@ -0,0 +1,83 @@
+/**
+ * Fusion.Widget.FeatureInfo
+ *
+ * $Id: $
+ *
+ * Copyright (c) 2007, DM Solutions Group Inc.
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+ /*****************************************************************************
+ * Class: Fusion.Widget.FeatureInfo
+ *
+ * The FeatureInfo widget displays information about selected polygons.
+ *
+ * If the Target property points to TaskPane widget, the task will be listed in
+ * the menu list of the TaskPane and loaded there.
+ * Otherwise if the target is an existing IFrame in the page it will be loaded
+ * there, otherwise it will open a new window with that name.
+ * **********************************************************************/
+
+
+Fusion.Widget.FeatureInfo = OpenLayers.Class(Fusion.Widget, {
+ uiClass: Jx.Button,
+ sFeatures : 'menubar=no,location=no,resizable=no,status=no',
+
+ initializeWidget: function(widgetTag) {
+ var json = widgetTag.extension;
+ this.sTarget = json.Target ? json.Target[0] : "FeatureInfoWindow";
+ this.sBaseUrl = Fusion.getFusionURL() + 'widgets/FeatureInfo/featureinfomain.php';
+ },
+
+ activate: function() {
+ var url = this.sBaseUrl;
+ //add in other parameters to the url here
+
+ var map = this.getMap();
+ var mapLayers = map.getAllMaps();
+ var taskPaneTarget = Fusion.getWidgetById(this.sTarget);
+ var pageElement = $(this.sTarget);
+
+ var params = [];
+ params.push('LOCALE='+Fusion.locale);
+ params.push('SESSION='+mapLayers[0].getSessionID());
+ params.push('MAPNAME='+mapLayers[0].getMapName());
+ if (taskPaneTarget || pageElement) {
+ params.push('POPUP=false');
+ } else {
+ params.push('POPUP=true');
+ }
+
+ if (url.indexOf('?') < 0) {
+ url += '?';
+ } else if (url.slice(-1) != '&') {
+ url += '&';
+ }
+ url += params.join('&');
+ if ( taskPaneTarget ) {
+ taskPaneTarget.setContent(url);
+ } else {
+ if ( pageElement ) {
+ pageElement.src = url;
+ } else {
+ window.open(url, this.sTarget, this.sWinFeatures);
+ }
+ }
+ }
+});
Property changes on: trunk/widgets/FeatureInfo.js
___________________________________________________________________
Name: svn:executable
+ *
More information about the fusion-commits
mailing list