[fusion-commits] r2407 - in trunk/widgets: . Redline
Redline/classes Redline/templates
svn_fusion at osgeo.org
svn_fusion at osgeo.org
Sat Jun 25 11:31:14 EDT 2011
Author: jng
Date: 2011-06-25 08:31:14 -0700 (Sat, 25 Jun 2011)
New Revision: 2407
Added:
trunk/widgets/Redline/classes/
trunk/widgets/Redline/classes/editcommand.php
trunk/widgets/Redline/classes/markupcommand.php
trunk/widgets/Redline/classes/markupeditor.php
trunk/widgets/Redline/classes/markupmanager.php
trunk/widgets/Redline/classes/markupschemafactory.php
trunk/widgets/Redline/editmarkup.php
trunk/widgets/Redline/getselectionxml.php
trunk/widgets/Redline/markupmain.php
trunk/widgets/Redline/newmarkup.php
trunk/widgets/Redline/styles/
trunk/widgets/Redline/templates/
trunk/widgets/Redline/templates/markuplayerdefinition.xml
Removed:
trunk/widgets/Redline/Redline.php
Modified:
trunk/widgets/Redline.js
trunk/widgets/Redline/Redline.css
Log:
#461: Replace redline widget. This redline widget is based on the original Generic Tasks markup example for the basic AJAX viewer, which has been updated to:
- Use updated MapGuide Web APIs
- Use the wrapper APIs provided by MapGuideViewerApi.js
- Save markups to the session repository instead of a hard-coded path in Library://Markup/. A session-based SDF datastore is used to catalog all client-side redlines feature sources that are created.
Modified: trunk/widgets/Redline/Redline.css
===================================================================
--- trunk/widgets/Redline/Redline.css 2011-06-23 10:15:24 UTC (rev 2406)
+++ trunk/widgets/Redline/Redline.css 2011-06-25 15:31:14 UTC (rev 2407)
@@ -1,34 +1,43 @@
-
-body#RedlineWidget {
- font-family: Arial, Helvetica, sans-serif;
- margin: 0px;
- padding: 0px;
- border: 0px;
+td.Title
+{
+ font-family: Arial, Helvetica, sans-serif;
+ font-weight: bold;
+ font-size: 13pt;
}
-
-#RedlineWidget h1 {
- font-size: 15px;
- font-weight: bold;
- margin: 0px;
- padding: 10px;
+td.SubTitle
+{
+ font-family: Arial, Helvetica, sans-serif;
+ font-weight: bold;
+ font-size: 8pt;
+ background-color: #DCDCDC;
+ color: black;
+ height: 20px;
}
-
-#RedlineWidget td,
-#RedlineWidget th {
- text-align: left;
- vertical-align: text-top;
- font-size: 12px;
- padding: 2px 10px;
- margin-bottom: 30px;
- border: 0px;
+td.Spacer
+{
+ height: 4px;
}
-
-#RedlineWidget th {
- font-weight: bold;
- vertical-align: text-top;
+.Swatch
+{
+ border: black 1px solid;
+ height: 16px;
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 10pt;
}
-
-#RedlineWidgetFeatureList {
- min-width: 250px;
- width: 250px;
+td.InfoText
+{
+ background-color: #FFFFCC;
+ color: #666666;
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 8pt;
}
+.RegText
+{
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 8pt;
+}
+.Ctrl
+{
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 8pt;
+}
Deleted: trunk/widgets/Redline/Redline.php
===================================================================
--- trunk/widgets/Redline/Redline.php 2011-06-23 10:15:24 UTC (rev 2406)
+++ trunk/widgets/Redline/Redline.php 2011-06-25 15:31:14 UTC (rev 2407)
@@ -1,204 +0,0 @@
-<?php
-/**
- * Measure
- *
- * $Id: Measure.php 1665 2008-11-12 21:46:54Z madair $
- *
- * 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.
- */
-
-/*****************************************************************************
- * Redline panel. It also allows a user to upload a file on the server.
- * The max file size should be setted in the php5.ini.
- *****************************************************************************/
-
-$fusionMGpath = '../../layers/MapGuide/php/';
-include $fusionMGpath . 'Common.php';
-
-SetLocalizedFilesPath(GetLocalizationPath());
-if(isset($_REQUEST['LOCALE'])) {
- $locale = $_REQUEST['LOCALE'];
-} else {
- $locale = GetDefaultLocale();
-}
-
-$optionLocal = GetLocalizedString('REDLINEOPTIONS', $locale );
-$selectLayerLocal = GetLocalizedString('REDLINESELECTLAYER', $locale );
-$newLocal = GetLocalizedString('REDLINENEW', $locale );
-$renameLocal = GetLocalizedString('REDLINERENAME', $locale );
-$removeLocal = GetLocalizedString('REDLINEREMOVE', $locale );
-$drawLocal = GetLocalizedString('REDLINEDRAW', $locale );
-$pointLocal = GetLocalizedString('REDLINEPOINT', $locale );
-$lineLocal = GetLocalizedString('REDLINELINE', $locale );
-$rectangleLocal = GetLocalizedString('REDLINERECTANGLE', $locale );
-$polygonLocal = GetLocalizedString('REDLINEPOLYGON', $locale );
-$saveLocal = GetLocalizedString('REDLINESAVE', $locale );
-$uploadLocal = GetLocalizedString('REDLINEUPLOAD', $locale );
-$featuresLocal = GetLocalizedString('REDLINEFEATURES', $locale );
-
-$fileUpload = false;
-
-$action = $_POST['action'];
-$file = $_GET['file'];
-if (isset($file)) { // it's a uploaded file request
- returnFile($file);
-}
-else {
- if (isset($action) && ($action == 'upload') && ($_FILES['uploadedfile']['error'] == UPLOAD_ERR_OK)) {
- $fileUpload = true;
-
- $target_path = tempnam(sys_get_temp_dir(), preg_replace("/\.[^\.]+$/", "", basename( $_FILES['uploadedfile']['name'])).'_');
-
- if (file_exists($target_path)) {
- unlink($target_path);
- }
- $target_path = $target_path.'.gml';
- $uploadedFilename = basename($target_path);
- if ((!move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path))) {
- $fileUpload = false;
- }
- }
- else if (isset($action)){ $noFile = 1;}
-}
-?>
-
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
- "http://www.w3.org/TR/html4/strict.dtd">
-<html>
- <head>
- <meta http-equiv="Content-type" content="text/html; charset=utf-8">
- <title>RedlineTaskPane</title>
- <style type="text/css" media="screen">
- @import url(Redline.css);
- </style>
- </head>
- <body id="RedlineWidget" onload="panelLoaded()">
- <script type="text/javascript">
- function panelLoaded() {
- div = document.createElement("div");
- div.innerHTML = "<div id=\"panelIsLoaded\"/>";
- document.body.appendChild(div);
- <? if ($fileUpload) { ?>
- div = document.createElement("div");
- div.innerHTML = "<div id=\"uploadedFileName\" value=\"<?= $uploadedFilename ?>\"/>";
- document.body.appendChild(div);
- <? } ?>
- <? if (isset($noFile)) { echo "alert('Please select a file.');"; } ?>
-
- }
- </script>
-
- <table id="RedlineWidgetOptions" borders="1" width="100%">
- <tr>
- <td style="font-family: Arial, Helvetica, sans-serif; font-weight: bold; font-size: 13pt">
- <?php echo $optionLocal ?>
- <hr>
- </td>
- </tr>
- <tr>
- <td style="font-family: Arial, Helvetica, sans-serif; font-weight: bold; font-size: 8pt; background-color: #DCDCDC; color: black; height: 20px;"><?php echo $selectLayerLocal ?></td>
- </tr>
- <tr>
- <td>
- <select id="RedlineWidgetLayerList"></select>
- </td>
- </tr>
- <tr>
- <td>
- <button id="RedlineWidgetNewLayerButton"><?php echo $newLocal ?></button>
- <button id="RedlineWidgetRenameLayerButton"><?php echo $renameLocal ?></button>
- <button id="RedlineWidgetRemoveLayerButton"><?php echo $removeLocal ?></button>
- </td>
- </tr>
- <tr>
- <td style="font-family: Arial, Helvetica, sans-serif; font-weight: bold; font-size: 8pt; background-color: #DCDCDC; color: black; height: 20px;"><?php echo $drawLocal ?></td>
- </tr>
- <tr>
- <td>
- <input id="RedlineWidgetPointRadio" type="radio" name="RedlineWidgetDrawRadio"/>
- <label for="RedlineWidgetPointeRadio"><?php echo $pointLocal ?></label><br/>
- <input id="RedlineWidgetLineRadio" type="radio" name="RedlineWidgetDrawRadio"/>
- <label for="RedlineWidgetLineRadio"><?php echo $lineLocal ?></label><br/>
- <input id="RedlineWidgetRectangleRadio" type="radio" name="RedlineWidgetDrawRadio"/>
- <label for="RedlineWidgetRectangleRadio"><?php echo $rectangleLocal ?></label><br/>
- <input id="RedlineWidgetPolygonRadio" type="radio" name="RedlineWidgetDrawRadio"/>
- <label for="RedlineWidgetPolygonRadio"><?php echo $polygonLocal ?></label>
- </td>
- </tr>
- <tr>
- <td>
- <hr/>
- <button id="RedlineWidgetSaveButton"><?php echo $saveLocal ?></button>
- </td>
- </tr>
- <tr>
- <td id="RedlineWidgetUploadTd">
- <form id="RedlineWidgetUploadForm" enctype="multipart/form-data" action="Redline.php" method="post">
- <input type="file" name="uploadedfile"/>
- <input type="hidden" name="action" value="upload"/>
- <input type="hidden" name="LOCALE" value="<?=$locale?>"/>
- <br/>
- <input id="RedlineWidgetUploadButton" type="submit" name="submit_element" value="<?php echo $uploadLocal ?>" />
- </form>
- </td>
- </tr>
- <tr>
- <td><hr/></td>
- </tr>
- <tr>
- <td style="font-family: Arial, Helvetica, sans-serif; font-weight: bold; font-size: 8pt; background-color: #DCDCDC; color: black; height: 20px;">
- <?php echo $featuresLocal ?>
- </td>
- </tr>
- <tr>
- <td>
- <select id="RedlineWidgetFeatureList" size="10">
- </select>
- </td>
- </tr>
- <tr>
- <td>
- <button id="RedlineWidgetRenameFeatureButton"><?php echo $renameLocal ?></button>
- <button id="RedlineWidgetRemoveFeatureButton"><?php echo $removeLocal ?></button>
- </td>
- </tr>
- </table>
-
- </body>
- </html>
-
-
-<?php
-
-function returnFile($filename) {
-
-header("Content-type: text/xml");
-header("Content-Disposition: attachment; filename=$filename");
-
-$filename = sys_get_temp_dir().'/'.$filename;
-$handle = fopen($filename, "r");
-$contents = fread($handle, filesize($filename));
-fclose($handle);
-
-echo $contents;
-exit;
-}
-
-?>
Added: trunk/widgets/Redline/classes/editcommand.php
===================================================================
--- trunk/widgets/Redline/classes/editcommand.php (rev 0)
+++ trunk/widgets/Redline/classes/editcommand.php 2011-06-25 15:31:14 UTC (rev 2407)
@@ -0,0 +1,14 @@
+<?php
+
+class EditCommand
+{
+ const AddPoint = 1;
+ const AddLine = 2;
+ const AddLineString = 3;
+ const AddRectangle = 4;
+ const AddPolygon = 5;
+ const Delete = 6;
+ const Update = 7;
+}
+
+?>
\ No newline at end of file
Added: trunk/widgets/Redline/classes/markupcommand.php
===================================================================
--- trunk/widgets/Redline/classes/markupcommand.php (rev 0)
+++ trunk/widgets/Redline/classes/markupcommand.php 2011-06-25 15:31:14 UTC (rev 2407)
@@ -0,0 +1,13 @@
+<?php
+
+class MarkupCommand
+{
+ const Create = 1;
+ const Open = 2;
+ const Delete = 3;
+ const Refresh = 4;
+ const Edit = 5;
+ const Close = 6;
+}
+
+?>
\ No newline at end of file
Added: trunk/widgets/Redline/classes/markupeditor.php
===================================================================
--- trunk/widgets/Redline/classes/markupeditor.php (rev 0)
+++ trunk/widgets/Redline/classes/markupeditor.php 2011-06-25 15:31:14 UTC (rev 2407)
@@ -0,0 +1,217 @@
+<?php
+
+require_once 'classes/markupmanager.php';
+
+class MarkupEditor
+{
+ private $args = null;
+ private $site = null;
+
+ function __construct($args)
+ {
+ $this->args = $args;
+ $this->site = new MgSiteConnection();
+ $this->site->Open(new MgUserInformation($args['SESSION']));
+ }
+
+ function GetResourceIdPrefix()
+ {
+ return "Session:" . $this->args["SESSION"] . "//";
+ }
+
+ function GetMarkupLayer()
+ {
+ return $this->args['OPENMARKUP'];
+ }
+
+ function GetMarkupName()
+ {
+ $resId = new MgResourceIdentifier($this->GetMarkupLayer());
+ return $resId->GetName();
+ }
+
+ function GetMarkupFeatures()
+ {
+ $features = array();
+
+ $featureService = $this->site->CreateService(MgServiceType::FeatureService);
+ $featureSourceId = new MgResourceIdentifier($this->GetResourceIdPrefix() . $this->GetMarkupName() . '.FeatureSource');
+
+ $featureReader = $featureService->SelectFeatures($featureSourceId, 'Markup', null);
+ while ($featureReader->ReadNext())
+ {
+ $id = $featureReader->GetInt32('ID');
+ $text = trim($featureReader->GetString('Text'));
+ $features[$id] = $text;
+ }
+
+ return $features;
+ }
+
+ function GetTransform()
+ {
+ $coordSysFactory = new MgCoordinateSystemFactory();
+ $resourceService = $this->site->CreateService(MgServiceType::ResourceService);
+ $featureService = $this->site->CreateService(MgServiceType::FeatureService);
+
+ $featureSourceId = new MgResourceIdentifier($this->GetResourceIdPrefix() . $this->GetMarkupName() . '.FeatureSource');
+ $wkt = null;
+
+ //Get the WKT from spatial context, because SDF only supports one spatial context it will be the first one
+ $scReader = $featureService->GetSpatialContexts($featureSourceId, true);
+ if ($scReader->ReadNext())
+ $wkt = $scReader->GetCoordinateSystemWkt();
+ $scReader->Close();
+
+ $map = new MgMap();
+ $map->Open($resourceService, $this->args['MAPNAME']);
+
+ if (null == $wkt)
+ return null; //It's bunk. Assume map SRS
+
+ if (strcmp($wkt, $map->GetMapSRS()) == 0)
+ return null; //Identical. No transformation needed
+
+ $source = $coordSysFactory->Create($map->GetMapSRS());
+ if (null != $wkt)
+ $target = $coordSysFactory->Create($wkt);
+
+ return $coordSysFactory->GetTransform($source, $target);
+ }
+
+ function AddPoint()
+ {
+ $geometryFactory = new MgGeometryFactory();
+ $agfWriter = new MgAgfReaderWriter();
+
+ $vertices = explode(',', $this->args['GEOMETRY']);
+
+ $coord = $geometryFactory->CreateCoordinateXY((double) $vertices[0], (double) $vertices[1]);
+ $point = $geometryFactory->CreatePoint($coord);
+
+ $trans = $this->GetTransform();
+ if (null != $trans)
+ $point = $point->Transform($trans);
+
+ $byteReader = $agfWriter->Write($point);
+
+ $propertyValues = new MgPropertyCollection();
+ $propertyValues->Add(new MgStringProperty('Text', $this->args['TEXT']));
+ $propertyValues->Add(new MgGeometryProperty('Geometry', $byteReader));
+
+ $this->InsertMarkupFeature($propertyValues);
+ }
+
+ function AddLineString()
+ {
+ $geometryFactory = new MgGeometryFactory();
+ $agfWriter = new MgAgfReaderWriter();
+
+ $vertices = explode(',', $this->args['GEOMETRY']);
+ $count = $vertices[0];
+
+ $coords = new MgCoordinateCollection();
+ for ($i = 0; $i < $count; $i++)
+ {
+ $coord = $geometryFactory->CreateCoordinateXY((double) $vertices[($i * 2) + 1], (double) $vertices[($i * 2) + 2]);
+ $coords->Add($coord);
+ }
+
+ $lineString = $geometryFactory->CreateLineString($coords);
+
+ $trans = $this->GetTransform();
+ if (null != $trans)
+ $lineString = $lineString->Transform($trans);
+
+ $byteReader = $agfWriter->Write($lineString);
+
+ $propertyValues = new MgPropertyCollection();
+ $propertyValues->Add(new MgStringProperty('Text', $this->args['TEXT']));
+ $propertyValues->Add(new MgGeometryProperty('Geometry', $byteReader));
+
+ $this->InsertMarkupFeature($propertyValues);
+ }
+
+ function AddPolygon()
+ {
+ $geometryFactory = new MgGeometryFactory();
+ $agfWriter = new MgAgfReaderWriter();
+
+ $vertices = explode(',', $this->args['GEOMETRY']);
+ $count = $vertices[0];
+
+ $coords = new MgCoordinateCollection();
+ for ($i = 0; $i < $count; $i++)
+ {
+ $coord = $geometryFactory->CreateCoordinateXY((double) $vertices[($i * 2) + 1], (double) $vertices[($i * 2) + 2]);
+ $coords->Add($coord);
+ }
+
+ $linearRing = $geometryFactory->CreateLinearRing($coords);
+ $polygon = $geometryFactory->CreatePolygon($linearRing, null);
+
+ $trans = $this->GetTransform();
+ if (null != $trans)
+ $polygon = $polygon->Transform($trans);
+
+ $byteReader = $agfWriter->Write($polygon);
+
+ $propertyValues = new MgPropertyCollection();
+ $propertyValues->Add(new MgStringProperty('Text', $this->args['TEXT']));
+ $propertyValues->Add(new MgGeometryProperty('Geometry', $byteReader));
+
+ $this->InsertMarkupFeature($propertyValues);
+ }
+
+ function InsertMarkupFeature($propertyValues)
+ {
+ $featureService = $this->site->CreateService(MgServiceType::FeatureService);
+ $featureSourceId = new MgResourceIdentifier($this->GetResourceIdPrefix() . $this->GetMarkupName() . '.FeatureSource');
+
+ $commands = new MgFeatureCommandCollection();
+ $commands->Add(new MgInsertFeatures('Markup', $propertyValues));
+
+ $featureService->UpdateFeatures($featureSourceId, $commands, false);
+ }
+
+ function DeleteMarkup()
+ {
+ $featureService = $this->site->CreateService(MgServiceType::FeatureService);
+ $featureSourceId = new MgResourceIdentifier($this->GetResourceIdPrefix() . $this->GetMarkupName() . '.FeatureSource');
+
+ $commands = new MgFeatureCommandCollection();
+ $commands->Add(new MgDeleteFeatures('Markup', 'ID = ' . $this->args['MARKUPFEATURE']));
+
+ $featureService->UpdateFeatures($featureSourceId, $commands, false);
+ }
+
+ function UpdateMarkup()
+ {
+ $featureService = $this->site->CreateService(MgServiceType::FeatureService);
+ $featureSourceId = new MgResourceIdentifier($this->GetResourceIdPrefix() . $this->GetMarkupName() . '.FeatureSource');
+
+ $propertyValues = new MgPropertyCollection();
+ $propertyValues->Add(new MgStringProperty('Text', trim($this->args['UPDATETEXT'])));
+
+ $commands = new MgFeatureCommandCollection();
+ $commands->Add(new MgUpdateFeatures('Markup', $propertyValues, 'ID = ' . $this->args['MARKUPFEATURE']));
+
+ $featureService->UpdateFeatures($featureSourceId, $commands, false);
+ }
+
+ function GetSelectionXML()
+ {
+ $resourceService = $this->site->CreateService(MgServiceType::ResourceService);
+
+ $map = new MgMap();
+ $map->Open($resourceService, $this->args['MAPNAME']);
+ $markupLayer = $map->GetLayers()->GetItem('_' . $this->GetMarkupName());
+
+ $selection = new MgSelection($map);
+ $selection->AddFeatureIdInt32($markupLayer, 'MarkupSchema:Markup', (int) $this->args['MARKUPFEATURE']);
+
+ return $selection->ToXML();
+ }
+}
+
+?>
\ No newline at end of file
Added: trunk/widgets/Redline/classes/markupmanager.php
===================================================================
--- trunk/widgets/Redline/classes/markupmanager.php (rev 0)
+++ trunk/widgets/Redline/classes/markupmanager.php 2011-06-25 15:31:14 UTC (rev 2407)
@@ -0,0 +1,333 @@
+<?php
+
+require_once dirname(__FILE__).'/../../../layers/MapGuide/php/Constants.php';
+require_once 'classes/markupschemafactory.php';
+
+class MarkupManager
+{
+ const MARKUP_REGISTRY_NAME = 'MarkupRegistry';
+
+ private $args = null;
+ private $site = null;
+ private $markupRegistryId = null;
+
+ function __construct($args)
+ {
+ $this->args = $args;
+ $this->site = new MgSiteConnection();
+ $this->site->Open(new MgUserInformation($args['SESSION']));
+ $this->InitMarkupRegistry();
+ }
+
+ function InitMarkupRegistry()
+ {
+ //NOTE: EnumerateResources does not work for session repositories. So to be able to "enumerate"
+ //resources, we create a registry feature source that would store this information
+
+ $this->markupRegistryId = new MgResourceIdentifier($this->GetResourceIdPrefix().MarkupManager::MARKUP_REGISTRY_NAME.".FeatureSource");
+ $resourceService = $this->site->CreateService(MgServiceType::ResourceService);
+
+ //Create the markup registry feature source if it doesn't already exist
+ if (!$resourceService->ResourceExists($this->markupRegistryId))
+ {
+ $featureService = $this->site->CreateService(MgServiceType::FeatureService);
+
+ //Markup Registry Feature Source Schema
+ //
+ //Default
+ // MarkupRegistry
+ // ResourceId (String, Identity, Not Null)
+ // LayerDefintion (String, Not Null)
+ // Name (String, Not Null)
+
+ $markupRegSchema = new MgFeatureSchema("Default", "");
+ $markupRegClass = new MgClassDefinition();
+ $markupRegClass->SetName("MarkupRegistry");
+
+ $markupRegId = new MgDataPropertyDefinition("ResourceId");
+ $markupRegId->SetDataType(MgPropertyType::String);
+ $markupRegId->SetLength(1024);
+ $markupRegId->SetNullable(false);
+
+ $layerDefId = new MgDataPropertyDefinition("LayerDefinition");
+ $layerDefId->SetDataType(MgPropertyType::String);
+ $layerDefId->SetLength(1024);
+ $layerDefId->SetNullable(false);
+
+ $markupRegName = new MgDataPropertyDefinition("Name");
+ $markupRegName->SetDataType(MgPropertyType::String);
+ $markupRegName->SetLength(512);
+ $markupRegName->SetNullable(false);
+
+ $dataProps = $markupRegClass->GetProperties();
+ $dataProps->Add($markupRegId);
+ $dataProps->Add($layerDefId);
+ $dataProps->Add($markupRegName);
+
+ $idProps = $markupRegClass->GetIdentityProperties();
+ $idProps->Add($markupRegId);
+
+ $classes = $markupRegSchema->GetClasses();
+ $classes->Add($markupRegClass);
+
+ $createSdf = new MgCreateSdfParams("Default", "", $markupRegSchema);
+ $featureService->CreateFeatureSource($this->markupRegistryId, $createSdf);
+ }
+ }
+
+ function GetResourceIdPrefix()
+ {
+ return "Session:" . $this->args["SESSION"] . "//";
+ }
+
+ function GetAvailableMarkup()
+ {
+ $markup = array();
+
+ //Query the markup registry
+ $featureService = $this->site->CreateService(MgServiceType::FeatureService);
+ $query = new MgFeatureQueryOptions();
+ $fr = $featureService->SelectFeatures($this->markupRegistryId, "Default:MarkupRegistry", $query);
+ while($fr->ReadNext())
+ {
+ $resId = $fr->GetString("LayerDefinition");
+ $resName = $fr->GetString("Name");
+
+ $markup[$resId] = $resName;
+ }
+ $fr->Close();
+
+ /*
+ $resourceService = $this->site->CreateService(MgServiceType::ResourceService);
+ $resourceID = new MgResourceIdentifier("Library://Markup/");
+
+ try
+ {
+ $byteReader = $resourceService->EnumerateResources($resourceID, 1, "LayerDefinition");
+ $resourceListXML = $byteReader->ToString();
+
+ $doc = DOMDocument::loadXML($resourceListXML);
+ $nodeList = $doc->getElementsByTagName('ResourceId');
+
+ foreach ($nodeList as $node)
+ {
+ $resourceId = new MgResourceIdentifier($node->nodeValue);
+ $markup[$resourceId->ToString()] = $resourceId->GetName();
+ }
+ asort($markup);
+ }
+ catch (MgResourceNotFoundException $mge)
+ {
+ // If the Library://Markup folder does not exist, create it.
+ $resourceService->SetResource($resourceID, null, null);
+ }*/
+
+ return $markup;
+ }
+
+ function OpenMarkup()
+ {
+ $resourceService = $this->site->CreateService(MgServiceType::ResourceService);
+
+ $map = new MgMap();
+ $map->Open($resourceService, $this->args['MAPNAME']);
+
+ // Create the Layer Groups
+
+ $markupGroup = null;
+ $layerGroups = $map->GetLayerGroups();
+ if ($layerGroups->Contains('_Markup'))
+ {
+ $markupGroup = $layerGroups->GetItem('_Markup');
+ }
+ else
+ {
+ $markupGroup = new MgLayerGroup('_Markup');
+ $markupGroup->SetVisible(true);
+ $markupGroup->SetLegendLabel('Markup');
+ $markupGroup->SetDisplayInLegend(true);
+ $layerGroups->Add($markupGroup);
+ }
+
+ // Add the Markup Layer
+
+ $markupLayerResId = new MgResourceIdentifier($this->args['MARKUPLAYER']);
+ $markupLayer = new MgLayer($markupLayerResId, $resourceService);
+ $markupLayer->SetName('_' . $markupLayerResId->GetName());
+ $markupLayer->SetLegendLabel($markupLayerResId->GetName());
+ $markupLayer->SetDisplayInLegend(true);
+ $markupLayer->SetSelectable(true);
+ $markupLayer->SetGroup($markupGroup);
+ $map->GetLayers()->Insert(0, $markupLayer);
+
+ $map->Save($resourceService);
+ }
+
+ function CloseMarkup()
+ {
+ $resourceService = $this->site->CreateService(MgServiceType::ResourceService);
+
+ $map = new MgMap();
+ $map->Open($resourceService, $this->args['MAPNAME']);
+
+ // Add the Markup Layer
+
+ $markupLayerResId = new MgResourceIdentifier($this->args['OPENMARKUP']);
+ $index = $map->GetLayers()->IndexOf('_' . $markupLayerResId->GetName());
+ $map->GetLayers()->RemoveAt($index);
+
+ $map->Save($resourceService);
+ }
+
+ function CreateMarkup()
+ {
+ $resourceService = $this->site->CreateService(MgServiceType::ResourceService);
+ $featureService = $this->site->CreateService(MgServiceType::FeatureService);
+
+ $map = new MgMap();
+ $map->Open($resourceService, $this->args['MAPNAME']);
+
+ // Create the Markup Feature Source (SDF)
+
+ $markupSdfResId = new MgResourceIdentifier($this->GetResourceIdPrefix() . $this->args['MARKUPNAME'] . '.FeatureSource');
+
+ $markupSchema = MarkupSchemaFactory::CreateMarkupSchema();
+ $sdfParams = new MgCreateSdfParams('Default', $map->GetMapSRS(), $markupSchema);
+ $featureService->CreateFeatureSource($markupSdfResId, $sdfParams);
+
+ // Create the Markup Layer Definition
+
+ $hexFgTransparency = sprintf("%02x", 255 * (100 - $this->args['FILLTRANSPARENCY']) / 100); // Convert % to an alpha value
+ $hexBgTransparency = $this->args['FILLBACKTRANS'] ? "FF" : "00"; // All or nothing
+ $bold = array_key_exists('LABELBOLD', $this->args) ? "true" : "false";
+ $italic = array_key_exists('LABELITALIC', $this->args) ? "true" : "false";
+ $underline = array_key_exists('LABELUNDERLINE', $this->args) ? "true" : "false";
+
+ $markupLayerDefinition = file_get_contents("templates/markuplayerdefinition.xml");
+ $markupLayerDefinition = sprintf($markupLayerDefinition,
+ $markupSdfResId->ToString(), //<ResourceId> - Feature Source
+ $this->args['LABELSIZEUNITS'], //<Unit> - Mark Label
+ $this->args['LABELFONTSIZE'], //<SizeX> - Mark Label Size
+ $this->args['LABELFONTSIZE'], //<SizeY> - Mark Label Size
+ 'FF' . $this->args['LABELFORECOLOR'], //<ForegroundColor> - Mark Label
+ 'FF' . $this->args['LABELBACKCOLOR'], //<BackgroundColor> - Mark Label
+ $this->args['LABELBACKSTYLE'], //<BackgroundStyle> - Mark Label
+ $bold, //<Bold> - Mark Label
+ $italic, //<Bold> - Mark Label
+ $underline, //<Underlined> - Mark Label
+ $this->args['MARKERSIZEUNITS'], //<Unit> - Mark
+ $this->args['MARKERSIZE'], //<SizeX> - Mark
+ $this->args['MARKERSIZE'], //<SizeY> - Mark
+ $this->args['MARKERTYPE'], //<Shape> - Mark
+ 'FF' . $this->args['MARKERCOLOR'], //<ForegroundColor> - Mark
+ 'FF' . $this->args['MARKERCOLOR'], //<Color> - Mark
+ $this->args['LABELSIZEUNITS'], //<Unit> - Line Label
+ $this->args['LABELFONTSIZE'], //<SizeX> - Line Label Size
+ $this->args['LABELFONTSIZE'], //<SizeY> - Line Label Size
+ 'FF' . $this->args['LABELFORECOLOR'], //<ForegroundColor> - Line Label
+ 'FF' . $this->args['LABELBACKCOLOR'], //<BackgroundColor> - Line Label
+ $this->args['LABELBACKSTYLE'], //<BackgroundStyle> - Line Label
+ $bold, //<Bold> - Line Label
+ $italic, //<Bold> - Line Label
+ $underline, //<Underlined> - Line Label
+ $this->args['LINEPATTERN'], //<LineStyle> - Line
+ $this->args['LINETHICKNESS'], //<Thickness> - Line
+ 'FF' . $this->args['LINECOLOR'], //<Color> - Line
+ $this->args['LINESIZEUNITS'], //<Unit> - Line
+ $this->args['LABELSIZEUNITS'], //<Unit> - Polygon Label
+ $this->args['LABELFONTSIZE'], //<SizeX> - Polygon Label Size
+ $this->args['LABELFONTSIZE'], //<SizeY> - Polygon Label Size
+ 'FF' . $this->args['LABELFORECOLOR'], //<ForegroundColor> - Polygon Label
+ 'FF' . $this->args['LABELBACKCOLOR'], //<BackgroundColor> - Polygon Label
+ $this->args['LABELBACKSTYLE'], //<BackgroundStyle> - Polygon Label
+ $bold, //<Bold> - Polygon Label
+ $italic, //<Bold> - Polygon Label
+ $underline, //<Underlined> - Polygon Label
+ $this->args['FILLPATTERN'], //<FillPattern> - Fill
+ $hexFgTransparency . $this->args['FILLFORECOLOR'], //<ForegroundColor> - Fill
+ $hexBgTransparency . $this->args['FILLBACKCOLOR'], //<BackgroundColor> - Fill
+ $this->args['BORDERPATTERN'], //<LineStyle> - Fill
+ $this->args['BORDERTHICKNESS'], //<Thickness> - Fill
+ 'FF' . $this->args['BORDERCOLOR'], //<Color> - Fill
+ $this->args['BORDERSIZEUNITS']); //<Unit> - Fill
+
+ $byteSource = new MgByteSource($markupLayerDefinition, strlen($markupLayerDefinition));
+ $layerDefId = new MgResourceIdentifier($this->GetResourceIdPrefix() . $this->args['MARKUPNAME'] . '.LayerDefinition');
+ $resourceService->SetResource($layerDefId, $byteSource->GetReader(), null);
+
+ //Register markup with markup registry
+ $props = new MgPropertyCollection();
+ $props->Add(new MgStringProperty("ResourceId", $markupSdfResId->ToString()));
+ $props->Add(new MgStringProperty("LayerDefinition", $layerDefId->ToString()));
+ $props->Add(new MgStringProperty("Name", $layerDefId->GetName()));
+ $insertCmd = new MgInsertFeatures("Default:MarkupRegistry", $props);
+
+ $cmds = new MgFeatureCommandCollection();
+ $cmds->Add($insertCmd);
+
+ $res = $featureService->UpdateFeatures($this->markupRegistryId, $cmds, false);
+ MarkupManager::CleanupReaders($res);
+ }
+
+ //Utility function to close all feature readers in a MgPropertyCollection
+ static function CleanupReaders($propCol)
+ {
+ for ($i = 0; $i < $propCol->GetCount(); $i++)
+ {
+ $prop = $propCol->GetItem($i);
+ if ($prop->GetPropertyType() == MgPropertyType::Feature)
+ {
+ $fr = $prop->GetValue();
+ $fr->Close();
+ }
+ }
+ }
+
+ function DeleteMarkup()
+ {
+ $resourceService = $this->site->CreateService(MgServiceType::ResourceService);
+ $featureService = $this->site->CreateService(MgServiceType::FeatureService);
+
+ $markupLayerResId = new MgResourceIdentifier($this->args['MARKUPLAYER']);
+ $markupSdfResId = new MgResourceIdentifier($this->GetResourceIdPrefix() . $markupLayerResId->GetName() . '.FeatureSource');
+
+ $resourceService->DeleteResource($markupLayerResId);
+ $resourceService->DeleteResource($markupSdfResId);
+
+ //Delete from markup registry
+ $delete = new MgDeleteFeatures("Default:MarkupRegistry", "ResourceId = '" . $markupSdfResId->ToString() . "' AND LayerDefinition = '" . $markupLayerResId->ToString() . "'");
+ $cmds = new MgFeatureCommandCollection();
+ $cmds->Add($delete);
+
+ $res = $featureService->UpdateFeatures($this->markupRegistryId, $cmds, false);
+ }
+
+ function GetOpenMarkup()
+ {
+ $openMarkup = array();
+
+ $resourceService = $this->site->CreateService(MgServiceType::ResourceService);
+
+ $map = new MgMap();
+ $map->Open($resourceService, $this->args['MAPNAME']);
+
+ $layerGroups = $map->GetLayerGroups();
+ if ($layerGroups->Contains('_Markup'))
+ {
+ $layers = $map->GetLayers();
+
+ for ($i = 0; $i < $layers->GetCount(); $i++)
+ {
+ $layer = $layers->GetItem($i);
+ if (($layer->GetGroup() != null) and ($layer->GetGroup()->GetName() == '_Markup'))
+ {
+ $openMarkup[$this->GetResourceIdPrefix() . $layer->GetLegendLabel() . '.LayerDefinition'] = $layer->GetLegendLabel();
+ }
+ }
+ asort($openMarkup);
+ }
+ return $openMarkup;
+ }
+}
+
+?>
\ No newline at end of file
Added: trunk/widgets/Redline/classes/markupschemafactory.php
===================================================================
--- trunk/widgets/Redline/classes/markupschemafactory.php (rev 0)
+++ trunk/widgets/Redline/classes/markupschemafactory.php 2011-06-25 15:31:14 UTC (rev 2407)
@@ -0,0 +1,65 @@
+<?php
+
+class MarkupSchemaFactory
+{
+ static function CreateIDProperty()
+ {
+ $idProperty = new MgDataPropertyDefinition('ID');
+ $idProperty->SetDataType(MgPropertyType::Int32);
+ $idProperty->SetReadOnly(true);
+ $idProperty->SetNullable(false);
+ $idProperty->SetAutoGeneration(true);
+
+ return $idProperty;
+ }
+
+ static function CreateTextProperty($length)
+ {
+ $textProperty = new MgDataPropertyDefinition('Text');
+ $textProperty->SetDataType(MgPropertyType::String);
+ $textProperty->SetLength($length);
+
+ return $textProperty;
+ }
+
+ static function CreateGeometryProperty($geomType)
+ {
+ $geometryProperty = new MgGeometricPropertyDefinition('Geometry');
+ $geometryProperty->SetGeometryTypes($geomType);
+ $geometryProperty->SetHasElevation(false);
+ $geometryProperty->SetHasMeasure(false);
+ $geometryProperty->SetReadOnly(false);
+ $geometryProperty->SetSpatialContextAssociation('Default');
+
+ return $geometryProperty;
+ }
+
+ static function CreateMarkupClass()
+ {
+ $markupClass = new MgClassDefinition();
+ $markupClass->SetName('Markup');
+ $properties = $markupClass->GetProperties();
+
+ $idProperty = MarkupSchemaFactory::CreateIDProperty();
+ $properties->Add($idProperty);
+ $properties->Add(MarkupSchemaFactory::CreateTextProperty(255));
+ $properties->Add(MarkupSchemaFactory::CreateGeometryProperty(MgFeatureGeometricType::Point | MgFeatureGeometricType::Curve | MgFeatureGeometricType::Surface));
+
+ $markupClass->GetIdentityProperties()->Add($idProperty);
+ $markupClass->SetDefaultGeometryPropertyName('Geometry');
+
+ return $markupClass;
+ }
+
+ static function CreateMarkupSchema()
+ {
+ $markupSchema = new MgFeatureSchema();
+ $markupSchema->SetName('MarkupSchema');
+
+ $markupSchema->GetClasses()->Add(MarkupSchemaFactory::CreateMarkupClass());
+
+ return $markupSchema;
+ }
+}
+
+?>
Added: trunk/widgets/Redline/editmarkup.php
===================================================================
--- trunk/widgets/Redline/editmarkup.php (rev 0)
+++ trunk/widgets/Redline/editmarkup.php 2011-06-25 15:31:14 UTC (rev 2407)
@@ -0,0 +1,370 @@
+<?php
+ require_once 'classes/markupeditor.php';
+ require_once 'classes/editcommand.php';
+
+ $args = ($_SERVER['REQUEST_METHOD'] == "POST") ? $_POST : $_GET;
+
+ $refreshMap = false;
+ $errorMsg = null;
+ $errorDetail = null;
+
+ try
+ {
+ $markupEditor = new MarkupEditor($args);
+
+ if (array_key_exists('EDITCOMMAND', $args))
+ {
+ $cmd = $args['EDITCOMMAND'];
+ switch ($cmd) {
+ case EditCommand::AddPoint:
+ $markupEditor->AddPoint();
+ $refreshMap = true;
+ break;
+ case EditCommand::AddLine:
+ case EditCommand::AddLineString:
+ $markupEditor->AddLineString();
+ $refreshMap = true;
+ break;
+ case EditCommand::AddRectangle:
+ case EditCommand::AddPolygon:
+ $markupEditor->AddPolygon();
+ $refreshMap = true;
+ break;
+ case EditCommand::Delete:
+ $markupEditor->DeleteMarkup();
+ $refreshMap = true;
+ break;
+ case EditCommand::Update:
+ $markupEditor->UpdateMarkup();
+ $refreshMap = true;
+ break;
+
+ }
+ }
+
+ $markupFeatures = $markupEditor->GetMarkupFeatures();
+ }
+ catch (MgException $e)
+ {
+ $errorMsg = $e->GetMessage();
+ $errorDetail = $e->GetDetails();
+ }
+?>
+<html>
+<head>
+ <title>Edit Markup</title>
+ <link rel="stylesheet" href="Redline.css" type="text/css">
+ <script language="javascript" src="../../layers/MapGuide/MapGuideViewerApi.js"></script>
+ <script language="javascript" src="../../common/browserdetect.js"></script>
+ <script language="javascript">
+ var session = '<?= $args['SESSION'] ?>';
+ var mapName = '<?= $args['MAPNAME'] ?>';
+
+ var CMD_ADD_POINT = <?= EditCommand::AddPoint ?>;
+ var CMD_ADD_LINE = <?= EditCommand::AddLine ?>;
+ var CMD_ADD_LINESTRING = <?= EditCommand::AddLineString ?>;
+ var CMD_ADD_RECTANGLE = <?= EditCommand::AddRectangle ?>;
+ var CMD_ADD_POLYGON = <?= EditCommand::AddPolygon ?>;
+ var CMD_DELETE = <?= EditCommand::Delete ?>;
+ var CMD_UPDATE = <?= EditCommand::Update ?>;
+
+ var EDIT_DEFAULT_HELP = "To begin select the type of markup to digitize.";
+ var EDIT_POINT_HELP = "Click the map to specify the location of the point.";
+ var EDIT_LINE_HELP = "Click and drag on the map to specify the start and end points of the line.";
+ var EDIT_LINESTRING_HELP = "Click the map to define each point of the line, Double Click on the final point to end.";
+ var EDIT_RECTANGLE_HELP = "Click on the map to specify the first corner and drag the mouse to define the rectangle.";
+ var EDIT_POLYGON_HELP = "Click the map to define each point of the polygon, Double Click on the final point to end.";
+
+ function SetDigitizeInfo(text)
+ {
+ var digitizeInfo = document.getElementById("digitizeInfo");
+ digitizeInfo.innerHTML = text;
+ }
+
+ function SubmitCommand(cmd)
+ {
+ var commandInput = document.getElementById("commandInput");
+ commandInput.value = cmd;
+
+ var editForm = document.getElementById("editForm");
+ editForm.submit();
+ }
+
+ function AddPoint()
+ {
+ SetDigitizeInfo(EDIT_POINT_HELP);
+ DigitizePoint(OnPointDigitized);
+ }
+
+ function AddLine()
+ {
+ SetDigitizeInfo(EDIT_LINE_HELP);
+ DigitizeLine(OnLineStringDigitized);
+ }
+
+ function AddLineString()
+ {
+ SetDigitizeInfo(EDIT_LINESTRING_HELP);
+ DigitizeLineString(OnLineStringDigitized);
+ }
+
+ function AddRectangle()
+ {
+ SetDigitizeInfo(EDIT_RECTANGLE_HELP);
+ DigitizeRectangle(OnRectangleDigitized);
+ }
+
+ function AddPolygon()
+ {
+ SetDigitizeInfo(EDIT_POLYGON_HELP);
+ DigitizePolygon(OnPolyonDigitized);
+ }
+
+ function PromptAndSetMarkupText()
+ {
+ var textInput = document.getElementById("textInput");
+
+ textLabel = window.prompt("Enter a label for the markup item", "");
+ textInput.value = (textLabel != null) ? textLabel : "";
+
+ ClearDigitization();
+ }
+
+ function OnPointDigitized(point)
+ {
+ PromptAndSetMarkupText();
+
+ var geometryInput = document.getElementById("geometryInput");
+ geometryInput.value = point.X + "," + point.Y;
+
+ SubmitCommand(CMD_ADD_POINT);
+ }
+
+ function OnLineStringDigitized(lineString)
+ {
+ PromptAndSetMarkupText();
+
+ var geomText = lineString.Count;
+ for (var i = 0; i < lineString.Count; i++)
+ {
+ geomText += "," + lineString.Point(i).X + "," + lineString.Point(i).Y;
+ }
+
+ var geometryInput = document.getElementById("geometryInput");
+ geometryInput.value = geomText;
+
+ SubmitCommand(CMD_ADD_LINESTRING);
+ }
+
+ function OnRectangleDigitized(rectangle)
+ {
+ PromptAndSetMarkupText();
+
+ var geometryInput = document.getElementById("geometryInput");
+ geometryInput.value = "5,"
+ + rectangle.Point1.X + "," + rectangle.Point1.Y + ","
+ + rectangle.Point2.X + "," + rectangle.Point1.Y + ","
+ + rectangle.Point2.X + "," + rectangle.Point2.Y + ","
+ + rectangle.Point1.X + "," + rectangle.Point2.Y + ","
+ + rectangle.Point1.X + "," + rectangle.Point1.Y;
+
+ SubmitCommand(CMD_ADD_RECTANGLE);
+ }
+
+ function OnPolyonDigitized(polygon)
+ {
+ PromptAndSetMarkupText();
+
+ var geomText = polygon.Count;
+ for (var i = 0; i < polygon.Count; i++)
+ {
+ geomText += "," + polygon.Point(i).X + "," + polygon.Point(i).Y;
+ }
+
+ var geometryInput = document.getElementById("geometryInput");
+ geometryInput.value = geomText;
+
+ SubmitCommand(CMD_ADD_POLYGON);
+ }
+
+ function SelectMarkup()
+ {
+ markupFeatures = document.getElementById("markupFeatures");
+
+ reqParams = "MAPNAME=" + encodeURIComponent(mapName);
+ reqParams += "&SESSION=" + encodeURIComponent(session);
+ reqParams += "&OPENMARKUP=" + encodeURIComponent('<?= $args['OPENMARKUP']; ?>');
+ reqParams += "&MARKUPFEATURE=" + markupFeatures.value;
+
+ if(msie)
+ reqHandler = new ActiveXObject("Microsoft.XMLHTTP");
+ else
+ reqHandler = new XMLHttpRequest();
+
+ reqHandler.open("POST", "getselectionxml.php", false);
+ reqHandler.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
+
+ reqHandler.send(reqParams);
+ if(reqHandler.responseXML)
+ {
+ SetSelectionXML(reqHandler.responseText);
+ }
+ }
+
+ function DeleteMarkup()
+ {
+ SubmitCommand(CMD_DELETE);
+ }
+
+ function UpdateMarkup()
+ {
+ SubmitCommand(CMD_UPDATE);
+ }
+
+ function CloseEditor()
+ {
+ var editForm = document.getElementById("editForm");
+ editForm.action = "markupmain.php";
+
+ editForm.submit();
+ }
+
+ function OnMarkupFeatureChange()
+ {
+ var markupFeatures = document.getElementById("markupFeatures");
+ var updateTextInput = document.getElementById("updateTextInput");
+ var selectBtn = document.getElementById("selectBtn");
+ var deleteBtn = document.getElementById("deleteBtn");
+ var updateBtn = document.getElementById("updateBtn");
+
+ if (markupFeatures.selectedIndex >= 0)
+ {
+ value = markupFeatures.options[markupFeatures.selectedIndex].text;
+ if (value != '[no text]')
+ updateTextInput.value = value;
+ else
+ updateTextInput.value = '';
+
+ selectBtn.disabled = false;
+ deleteBtn.disabled = false;
+ updateBtn.disabled = false;
+ }
+ else
+ {
+ updateTextInput.value = '';
+ selectBtn.disabled = true;
+ deleteBtn.disabled = true;
+ updateBtn.disabled = true;
+ }
+ }
+
+ function OnLoad()
+ {
+ OnMarkupFeatureChange();
+
+ <?php if ($refreshMap) { ?>
+ var map = parent.Fusion.getMapByName(mapName);
+ map.reloadMap();
+ <?php } ?>
+ SetDigitizeInfo(EDIT_DEFAULT_HELP);
+ }
+ </script>
+</head>
+
+<body onLoad="OnLoad()" marginwidth=5 marginheight=5 leftmargin=5 topmargin=5 bottommargin=5 rightmargin=5>
+
+<?php if ($errorMsg == null) { ?>
+
+<form action="editmarkup.php" method="post" enctype="application/x-www-form-urlencoded" id="editForm" target="_self">
+<table class="RegText" border="0" cellspacing="0" width="100%">
+ <tr>
+ <td colspan="2" class="Title">Edit Markup - <?= $markupEditor->GetMarkupName() ?><hr></td>
+ </tr>
+
+ <tr>
+ <td colspan="2" class="SubTitle">Add Markup</td>
+ </tr>
+ <tr>
+ <td colspan="2">Digitize markup:</td>
+ </tr>
+ <tr><td colspan="2" height="2px"></td></tr>
+ <tr>
+ <td colspan="2">
+ <input class="Ctrl" id="pointBtn" type="button" onClick="AddPoint()" value="Point" style="width:60px">
+ <input class="Ctrl" id="lineBtn" type="button" onClick="AddLine()" value="Line" style="width:60px">
+ <input class="Ctrl" id="lineStringBtn" type="button" onClick="AddLineString()" value="Line String" style="width:60px">
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2">
+ <input class="Ctrl" id="rectangleBtn" type="button" onClick="AddRectangle()" value="Rectangle" style="width:60px">
+ <input class="Ctrl" id="polygonBtn" type="button" onClick="AddPolygon()" value="Polygon" style="width:60px">
+ </td>
+ </tr>
+ <tr><td colspan="2" height="2px"></td></tr>
+ <tr>
+ <td class="InfoText" colspan="2" id="digitizeInfo"></td>
+ </tr>
+ <tr><td colspan="2"></td></tr>
+ <tr>
+ <td colspan="2" class="SubTitle">Modify Markup</td>
+ </tr>
+ <tr>
+ <td colspan="2">
+ <input class="Ctrl" name="UPDATETEXT" type="text" id="updateTextInput" maxlength="255" style="width:100%"><br></td>
+ </td>
+ </tr>
+ <tr>
+ <td class="RegText">
+ <select name="MARKUPFEATURE" size="15" class="Ctrl" id="markupFeatures" onChange="OnMarkupFeatureChange()" style="width: 100%">
+ <?php
+ $selected = 'selected';
+ foreach($markupFeatures as $markupId => $markupText) {
+ ?>
+ <option value="<?= $markupId ?>" <?=$selected ?> ><?= (strlen($markupText) > 0) ? $markupText : '[no text]' ?></option>
+ <?php
+ $selected = '';
+ }
+ ?>
+ </select>
+ </td>
+ </tr>
+ <tr><td colspan="2" height="2px"></td></tr>
+ <tr>
+ <td colspan="2">
+ <input class="Ctrl" id="selectBtn" type="button" onClick="SelectMarkup()" value="Select Markup" style="width:80px">
+ <input class="Ctrl" id="deleteBtn" type="button" onClick="DeleteMarkup()" value="Delete Markup" style="width:80px">
+ <input class="Ctrl" id="updateBtn" type="button" onClick="UpdateMarkup()" value="Update Text" style="width:80px">
+ </td>
+ </tr>
+ <tr><td colspan="2" height="2px"></td></tr>
+
+ <tr>
+ <td colspan="2" align="right">
+ <hr>
+ <input class="Ctrl" name="" type="button" onClick="CloseEditor()" value="Close" style="width:60px">
+ </td>
+ </tr>
+
+</table>
+<input name="SESSION" type="hidden" value="<?= $args['SESSION'] ?>">
+<input name="MAPNAME" type="hidden" value="<?= $args['MAPNAME'] ?>">
+<input name="OPENMARKUP" type="hidden" value="<?= $args['OPENMARKUP'] ?>">
+<input name="EDITCOMMAND" type="hidden" value="" id="commandInput">
+<input name="GEOMETRY" type="hidden" value="" id="geometryInput">
+<input name="TEXT" type="hidden" value="" id="textInput">
+</form>
+
+<?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>
Added: trunk/widgets/Redline/getselectionxml.php
===================================================================
--- trunk/widgets/Redline/getselectionxml.php (rev 0)
+++ trunk/widgets/Redline/getselectionxml.php 2011-06-25 15:31:14 UTC (rev 2407)
@@ -0,0 +1,11 @@
+<?php
+ $fusionMGpath = '../../layers/MapGuide/php/';
+ require_once $fusionMGpath . 'Common.php';
+ require_once 'classes/markupeditor.php';
+
+ $args = ($_SERVER['REQUEST_METHOD'] == "POST") ? $_POST : $_GET;
+ $markupEditor = new MarkupEditor($args);
+
+ header('Content-Type: text/xml');
+ echo $markupEditor->GetSelectionXML();
+?>
\ No newline at end of file
Added: trunk/widgets/Redline/markupmain.php
===================================================================
--- trunk/widgets/Redline/markupmain.php (rev 0)
+++ trunk/widgets/Redline/markupmain.php 2011-06-25 15:31:14 UTC (rev 2407)
@@ -0,0 +1,213 @@
+<?php
+ $fusionMGpath = '../../layers/MapGuide/php/';
+ require_once $fusionMGpath . 'Common.php';
+ require_once 'classes/markupmanager.php';
+ require_once 'classes/markupcommand.php';
+
+ $args = ($_SERVER['REQUEST_METHOD'] == "POST") ? $_POST : $_GET;
+
+ $refreshMap = false;
+ $errorMsg = null;
+ $errorDetail = null;
+
+ try
+ {
+ $markupManager = new MarkupManager($args);
+
+ if (array_key_exists('MARKUPCOMMAND', $args))
+ {
+ $cmd = $args['MARKUPCOMMAND'];
+ switch ($cmd) {
+ case MarkupCommand::Create:
+ $markupManager->CreateMarkup();
+ $refreshMap = true;
+ break;
+ case MarkupCommand::Open:
+ $markupManager->OpenMarkup();
+ $refreshMap = true;
+ break;
+ case MarkupCommand::Delete:
+ $markupManager->DeleteMarkup();
+ break;
+ case MarkupCommand::Refresh:
+ break;
+ case MarkupCommand::Close:
+ $markupManager->CloseMarkup();
+ $refreshMap = true;
+ break;
+ }
+ }
+
+ $availableMarkup = $markupManager->GetAvailableMarkup();
+ $openMarkup = $markupManager->GetOpenMarkup();
+
+ // Remove open markup from the list of available markup.
+
+ $availableMarkup = array_diff($availableMarkup, $openMarkup);
+ }
+ catch (MgException $mge)
+ {
+ $errorMsg = $mge->GetMessage();
+ $errorDetail = $mge->GetDetails();
+ }
+ catch (Exception $e)
+ {
+ $errorMsg = $e->GetMessage();
+ }
+?>
+<html>
+<head>
+ <title>Manage Markups</title>
+ <link rel="stylesheet" href="Redline.css" type="text/css">
+
+ <script language="javascript">
+ var session = '<?= $args['SESSION'] ?>';
+ var mapName = '<?= $args['MAPNAME'] ?>';
+
+ var CMD_NEW = <?= MarkupCommand::Create ?>;
+ var CMD_OPEN = <?= MarkupCommand::Open ?>;
+ var CMD_DELETE = <?= MarkupCommand::Delete ?>;
+ var CMD_REFRESH = <?= MarkupCommand::Refresh ?>;
+ var CMD_EDIT = <?= MarkupCommand::Edit ?>;
+ var CMD_CLOSE = <?= MarkupCommand::Close ?>;
+
+ function SubmitCommand(cmd)
+ {
+ var commandInput = document.getElementById("commandInput");
+ commandInput.value = cmd;
+
+ var markupForm = document.getElementById("markupForm");
+ if (cmd == CMD_NEW)
+ markupForm.action = "newmarkup.php";
+ else if (cmd == CMD_EDIT)
+ markupForm.action = "editmarkup.php";
+ else
+ markupForm.action = "markupmain.php";
+
+ markupForm.submit();
+ }
+
+ function OnAvailableMarkupChange()
+ {
+ var availableSelect = document.getElementById("availableMarkup");
+ var openBtn = document.getElementById("openBtn");
+ var deleteBtn = document.getElementById("deleteBtn");
+
+ if (availableSelect.selectedIndex >= 0)
+ {
+ openBtn.disabled = false;
+ deleteBtn.disabled = false;
+ }
+ else
+ {
+ openBtn.disabled = true;
+ deleteBtn.disabled = true;
+ }
+ }
+
+ function OnOpenMarkupChange()
+ {
+ var openSelect = document.getElementById("openMarkup");
+ var editBtn = document.getElementById("editBtn");
+ var closeBtn = document.getElementById("closeBtn");
+
+ if (openSelect.selectedIndex >= 0)
+ {
+ editBtn.disabled = false;
+ closeBtn.disabled = false;
+ }
+ else
+ {
+ editBtn.disabled = true;
+ closeBtn.disabled = true;
+ }
+ }
+
+ function OnLoad()
+ {
+ OnAvailableMarkupChange();
+ OnOpenMarkupChange();
+
+ <?php if ($refreshMap) { ?>
+ var map = parent.Fusion.getMapByName(mapName);
+ map.reloadMap();
+ <?php } ?>
+ }
+ </script>
+
+</head>
+
+<body onLoad="OnLoad()" marginwidth=5 marginheight=5 leftmargin=5 topmargin=5 bottommargin=5 rightmargin=5>
+
+<?php if ($errorMsg == null) { ?>
+
+<form action="" method="post" enctype="application/x-www-form-urlencoded" id="markupForm" target="_self">
+<table class="RegText" border="0" cellspacing="0" width="100%">
+ <tr><td class="Title">Manage Markup<hr></td></tr>
+ <tr><td class="SubTitle">Available Markup Layers</td></tr>
+ <tr>
+ <td class="RegText">
+ <select name="MARKUPLAYER" size="15" class="Ctrl" id="availableMarkup" onChange="OnAvailableMarkupChange()" style="width: 100%">
+ <?php
+ $selected = 'selected';
+ foreach($availableMarkup as $markupResId => $markupName) {
+ ?>
+ <option value="<?= $markupResId ?>" <?=$selected ?> ><?= $markupName ?></option>
+ <?php
+ $selected = '';
+ }
+ ?>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <input class="Ctrl" type="button" id="newBtn" onClick="SubmitCommand(CMD_NEW)" value="New" style="width:50px">
+ <input class="Ctrl" type="button" id="openBtn" onClick="SubmitCommand(CMD_OPEN)" value="Add To Map" style="width:90px">
+ <input class="Ctrl" type="button" id="deleteBtn" onClick="SubmitCommand(CMD_DELETE)" value="Delete" style="width:50px">
+ <input class="Ctrl" type="button" id="refreshBtn" onClick="SubmitCommand(CMD_REFRESH)" value="Refresh" style="width:50px">
+ <br><br>
+ </td>
+ </tr>
+ <tr><td class="SubTitle">Markup Layers on Map</td></tr>
+ <tr>
+ <td class="RegText">
+ <select name="OPENMARKUP" size="10" class="Ctrl" id="openMarkup" onChange="OnOpenMarkupChange()" style="width: 100%">
+ <?php
+ $selected = 'selected';
+ foreach($openMarkup as $markupLayer => $markupName) {
+ ?>
+ <option value="<?= $markupLayer ?>" <?=$selected ?> ><?= $markupName ?></option>
+ <?php
+ $selected = '';
+ }
+ ?>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <input class="Ctrl" type="button" id="editBtn" onClick="SubmitCommand(CMD_EDIT)" value="Add/Edit Markups" style="width:100px">
+ <input class="Ctrl" type="button" id="closeBtn" onClick="SubmitCommand(CMD_CLOSE)" value="Remove From Map" style="width:100px">
+ <br><br>
+ </td>
+ </tr>
+</table>
+<input name="SESSION" type="hidden" value="<?= $args['SESSION'] ?>">
+<input name="MAPNAME" type="hidden" value="<?= $args['MAPNAME'] ?>">
+<input name="MARKUPCOMMAND" type="hidden" value="" id="commandInput">
+</form>
+
+<?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>
Added: trunk/widgets/Redline/newmarkup.php
===================================================================
--- trunk/widgets/Redline/newmarkup.php (rev 0)
+++ trunk/widgets/Redline/newmarkup.php 2011-06-25 15:31:14 UTC (rev 2407)
@@ -0,0 +1,404 @@
+<?php
+ require_once 'classes/markupcommand.php';
+
+ $args = ($_SERVER['REQUEST_METHOD'] == "POST") ? $_POST : $_GET;
+
+ $errorMsg = null;
+ $errorDetail = null;
+?>
+<html>
+<head>
+ <title>New Markup Layer</title>
+ <link rel="stylesheet" href="Redline.css" type="text/css">
+
+ <script language="javascript">
+ var SET_MARKER_COLOR = 1;
+ var SET_LINE_COLOR = 2;
+ var SET_FILL_FORE_COLOR = 3;
+ var SET_FILL_BACK_COLOR = 4;
+ var SET_BORDER_COLOR = 5;
+ var SET_LABEL_FORE_COLOR = 6;
+ var SET_LABEL_BACK_COLOR = 7;
+ var setColor = 0;
+
+ var markerColor = "FF0000";
+ var lineColor = "0000FF";
+ var fillForeColor = "00FF00";
+ var fillBackColor = "00FF00";
+ var fillBackTrans = true;
+ var borderColor = "000000";
+ var labelForeColor = "000000";
+ var labelBackColor = "FFFFFF";
+
+ function CheckName()
+ {
+ var el = document.getElementById("markupName");
+ var mkName = el.value.replace(/^\s+|\s+$/g,"");
+ if (mkName == "") {
+ alert("Please enter a name for this new markup layer");
+ el.focus();
+ return false;
+ }
+ return true;
+ }
+
+ function PickColor(whichColor, allowTransparency, transparent)
+ {
+ var clr;
+ setColor = whichColor;
+
+ if (setColor == SET_MARKER_COLOR)
+ clr = markerColor;
+ else if (setColor == SET_LINE_COLOR)
+ clr = lineColor;
+ else if (setColor == SET_FILL_FORE_COLOR)
+ clr = fillForeColor;
+ else if (setColor == SET_FILL_BACK_COLOR)
+ clr = fillBackColor;
+ else if (setColor == SET_BORDER_COLOR)
+ clr = borderColor;
+ else if (setColor == SET_LABEL_FORE_COLOR)
+ clr = labelForeColor;
+ else if (setColor == SET_LABEL_BACK_COLOR)
+ clr = labelBackColor;
+ else
+ return;
+
+ height = allowTransparency? 470: 445;
+ w = window.open("../../../mapviewerphp/colorpicker.php?LOCALE=en&CLR=" + clr + "&ALLOWTRANS=" + (allowTransparency? "1":"0") + "&TRANS=" + (transparent?"1":"0"), "colorPicker", "toolbar=no,status=no,width=355,height=" + height);
+ w.focus();
+ }
+
+ function OnColorPicked(clr, trans)
+ {
+ if (setColor == SET_MARKER_COLOR)
+ markerColor = clr;
+ else if (setColor == SET_LINE_COLOR)
+ lineColor = clr;
+ else if (setColor == SET_FILL_FORE_COLOR)
+ fillForeColor = clr;
+ else if (setColor == SET_FILL_BACK_COLOR)
+ {
+ fillBackColor = clr;
+ fillBackTrans = trans;
+ }
+ else if (setColor == SET_BORDER_COLOR)
+ borderColor = clr;
+ else if (setColor == SET_LABEL_FORE_COLOR)
+ labelForeColor = clr;
+ else if (setColor == SET_LABEL_BACK_COLOR)
+ labelBackColor = clr;
+ else
+ return;
+
+ UpdateColors();
+ }
+
+ function UpdateColors()
+ {
+ var elt;
+ document.getElementById("markerColor").value = markerColor;
+ elt = document.getElementById("markerSwatch").style;
+ elt.backgroundColor = "#" + markerColor;
+ elt.color = "#" + markerColor;
+
+ document.getElementById("lineColor").value = lineColor;
+ elt = document.getElementById("lineSwatch").style;
+ elt.backgroundColor = "#" + lineColor;
+ elt.color = "#" + lineColor;
+
+ document.getElementById("fillForeColor").value = fillForeColor;
+ elt = document.getElementById("fillFgSwatch").style;
+ elt.backgroundColor = "#" + fillForeColor;
+ elt.color = "#" + fillForeColor;
+
+ document.getElementById("fillBackColor").value = fillBackColor;
+ document.getElementById("fillBackTrans").value = fillBackTrans;
+ elt = document.getElementById("fillBgSwatch").style;
+ elt.backgroundColor = fillBackTrans ? "#FFFFFF" : "#" + fillBackColor;
+ elt.color = fillBackTrans ? "#000000" : "#" + fillBackColor;
+
+ document.getElementById("borderColor").value = borderColor;
+ elt = document.getElementById("borderSwatch").style;
+ elt.backgroundColor = "#" + borderColor;
+ elt.color = "#" + borderColor;
+
+ document.getElementById("labelForeColor").value = labelForeColor;
+ elt = document.getElementById("labelFgSwatch").style;
+ elt.backgroundColor = "#" + labelForeColor;
+ elt.color = "#" + labelForeColor;
+
+ document.getElementById("labelBackColor").value = labelBackColor;
+ elt = document.getElementById("labelBgSwatch").style;
+ elt.backgroundColor = "#" + labelBackColor;
+ elt.color = "#" + labelBackColor;
+ }
+
+ </script>
+
+</head>
+
+<body marginwidth=5 marginheight=5 leftmargin=5 topmargin=5 bottommargin=5 rightmargin=5>
+
+<?php if ($errorMsg == null) { ?>
+
+<form action="markupmain.php" method="post" enctype="application/x-www-form-urlencoded" id="newMarkupLayerForm" target="_self">
+
+<input name="SESSION" type="hidden" value="<?= $args['SESSION'] ?>">
+<input name="MAPNAME" type="hidden" value="<?= $args['MAPNAME'] ?>">
+<input name="MARKUPCOMMAND" type="hidden" value="<?= MarkupCommand::Create ?>">
+
+<table class="RegText" border="0" cellspacing="0" width="100%%">
+ <tr><td id="elTitle" colspan="2" class="Title">New Markup Layer<hr></td></tr>
+
+ <tr><td colspan="2" class="SubTitle">Markup Layer Settings</td></tr>
+ <tr><td colspan="2">Markup name:</td></tr>
+ <tr><td colspan="2"><input class="Ctrl" id="markupName" name="MARKUPNAME" type="text" maxlength="255" style="width:100%"><br><br></td></tr>
+
+ <tr><td colspan="2" class="SubTitle">Point Style</td></tr>
+ <tr>
+ <td colspan="2">
+ Marker type:<br>
+ <select class="Ctrl" name="MARKERTYPE" size="1">
+ <option value="Square" selected="selected">Square</option>
+ <option value="Circle">Circle</option>
+ <option value="Triangle">Triangle</option>
+ <option value="Star">Star</option>
+ <option value="Cross">Cross</option>
+ <option value="X">X</option>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ Size units:<br>
+ <select class="Ctrl" name="MARKERSIZEUNITS" size="1">
+ <option value="Points" selected="selected">Points</option>
+ <option value="Inches">Inches</option>
+ <option value="Millimeters">Millimeters</option>
+ <option value="Centimeters">Centimeters</option>
+ <option value="Meters">Meters</option>
+ </select>
+ </td>
+ <td>
+ Marker size:<br>
+ <input class="Ctrl" name="MARKERSIZE" type="text" value="10">
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2">
+ Marker color:<br>
+ <span class="Swatch" id="markerSwatch" style="color: #ff0000; background-color: #ff0000"> transparent </span>
+ <input class="Ctrl" type="button" value="..." style="width: 22px;" onClick="PickColor(SET_MARKER_COLOR,false,false)">
+ <br><br>
+ </td>
+ </tr>
+
+ <tr><td colspan="2" class="SubTitle">Line Style</td></tr>
+ <tr>
+ <td colspan="2">
+ Line pattern:<br>
+ <select class="Ctrl" name="LINEPATTERN" size="1">
+ <option value="Solid" selected="selected">Solid</option>
+ <option value="Dash">Dash</option>
+ <option value="Dot">Dot</option>
+ <option value="DashDot">DashDot</option>
+ <option value="DashDotDot">DashDotDot</option>
+ <option value="Rail">Rail</option>
+ <option value="BORDER">Border</option>
+ <option value="DIVIDE">Divide</option>
+ <option value="FENCELINE1">FenceLine</option>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td width="50%">
+ Size units:<br>
+ <select class="Ctrl" name="LINESIZEUNITS" size="1">
+ <option value="Points">Points</option>
+ <option value="Inches">Inches</option>
+ <option value="Millimeters">Millimeters</option>
+ <option value="Centimeters" selected="selected">Centimeters</option>
+ <option value="Meters">Meters</option>
+ </select>
+ </td>
+ <td width="50%">
+ Line thickness:<br>
+ <input class="Ctrl" name="LINETHICKNESS" type="text" value="0">
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2">
+ Line color:<br>
+ <span class="Swatch" id="lineSwatch" style="color: #0000ff; background-color: #0000ff"> transparent </span>
+ <input class="Ctrl" type="button" value="..." style="width: 22px;" onClick="PickColor(SET_LINE_COLOR,false,false)">
+ <br><br>
+ </td>
+ </tr>
+
+
+ <tr><td colspan="2" class="SubTitle">Polygon Style</td></tr>
+ <tr>
+ <td width="50%">
+ Fill pattern:<br>
+ <select class="Ctrl" name="FILLPATTERN" size="1">
+ <option value="Solid" selected>Solid</option>
+ <option value="Net">Net</option>
+ <option value="Line">Line</option>
+ <option value="Line_45">Line_45</option>
+ <option value="Line_90">Line_90</option>
+ <option value="Line_135">Line_135</option>
+ <option value="Square">Square</option>
+ <option value="Box">Box</option>
+ <option value="Cross">Cross</option>
+ <option value="Dash">Dash</option>
+ <option value="Dolmit">Dolmit</option>
+ <option value="Hex">Hex</option>
+ <option value="Sacncr">Sacncr</option>
+ <option value="Steel">Steel</option>
+ </select>
+ </td>
+ <td width="50%">
+ Transparency:<br>
+ <input class="Ctrl" name="FILLTRANSPARENCY" type="text" maxlength="3" value="0" style="width:50px">%
+ </td>
+ </tr>
+ <tr>
+ <td width="50%" valign="top">
+ Foreground color:<br>
+ <span class="Swatch" id="fillFgSwatch" style="color: #00ff00; background-color: #00ff00"> transparent </span>
+ <input class="Ctrl" type="button" value="..." style="width: 22px;" onClick="PickColor(SET_FILL_FORE_COLOR,false,false)">
+ <br><br>
+ </td>
+ <td width="50%" valign="top">
+ Background color:<br>
+ <span class="Swatch" id="fillBgSwatch"> transparent </span>
+ <input class="Ctrl" type="button" value="..." style="width: 22px;" onClick="PickColor(SET_FILL_BACK_COLOR,true,fillBackTrans)">
+ <br>
+ </td>
+ </tr>
+ <tr><td colspan="2"><hr></td></tr>
+ <tr>
+ <td colspan="2">
+ Border pattern:<br>
+ <select class="Ctrl" name="BORDERPATTERN" size="1">
+ <option value="Solid" selected="selected">Solid</option>
+ <option value="Dash">Dash</option>
+ <option value="Dot">Dot</option>
+ <option value="DashDot">DashDot</option>
+ <option value="DashDotDot">DashDotDot</option>
+ <option value="Rail">Rail</option>
+ <option value="BORDER">Border</option>
+ <option value="DIVIDE">Divide</option>
+ <option value="FENCELINE1">FenceLine</option>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td width="50%">
+ Size units:<br>
+ <select class="Ctrl" name="BORDERSIZEUNITS" size="1">
+ <option value="Points">Points</option>
+ <option value="Inches">Inches</option>
+ <option value="Millimeters">Millimeters</option>
+ <option value="Centimeters" selected="selected">Centimeters</option>
+ <option value="Meters">Meters</option>
+ </select>
+ </td>
+ <td width="50%">
+ Border thickness:<br>
+ <input class="Ctrl" name="BORDERTHICKNESS" type="text" value="0">
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2">
+ Border color:<br>
+ <span class="Swatch" id="borderSwatch" style="color: #000000; background-color: #000000"> transparent </span>
+ <input class="Ctrl" type="button" value="..." style="width: 22px;" onClick="PickColor(SET_BORDER_COLOR,false,false)">
+ <br><br>
+ </td>
+ </tr>
+
+ <tr><td colspan="2" class="SubTitle">Label Style</td></tr>
+ <tr>
+ <td width="50%">
+ Size units:<br>
+ <select class="Ctrl" name="LABELSIZEUNITS" size="1">
+ <option value="Points" selected="selected">Points</option>
+ <option value="Inches">Inches</option>
+ <option value="Millimeters">Millimeters</option>
+ <option value="Centimeters">Centimeters</option>
+ <option value="Meters">Meters</option>
+ </select>
+ </td>
+ <td width="50%">
+ Label font size:<br>
+ <input class="Ctrl" name="LABELFONTSIZE" type="text" value="10">
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2" valign="middle">
+ <input name="LABELBOLD" type="checkbox" value="bold"><label>Bold</label>
+ <input name="LABELITALIC" type="checkbox" value="italic"><label>Italic</label>
+ <input name="LABELUNDERLINE" type="checkbox" value="underline"><label>Underline</label>
+ </td>
+ </tr>
+ <tr>
+ <td width="50%" valign="top">
+ Label color:<br>
+ <span class="Swatch" id="labelFgSwatch" style="color: #000000; background-color: #000000"> transparent </span>
+ <input class="Ctrl" type="button" value="..." style="width: 22px;" onClick="PickColor(SET_LABEL_FORE_COLOR,false,false)">
+ <br><br>
+ </td>
+ <td width="50%" valign="top">
+ Background color:<br>
+ <span class="Swatch" id="labelBgSwatch" style="color: #FFFFFF; background-color: #FFFFFF"> transparent </span>
+ <input class="Ctrl" type="button" value="..." style="width: 22px;" onClick="PickColor(SET_LABEL_BACK_COLOR,false,false)">
+ <br>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2">
+ Label background style:<br>
+ <select class="Ctrl" name="LABELBACKSTYLE" size="1">
+ <option value="Ghosted" selected="selected">Ghosted</option>
+ <option value="Opaque">Opaque</option>
+ <option value="Transparent">Transparent</option>
+ </select>
+ </td>
+ </tr>
+
+ <tr>
+ <td colspan="2" align="right">
+ <hr>
+ <input class="Ctrl" name="" type="submit" value="OK" onclick="return CheckName()" style="width:60px">
+ <input class="Ctrl" type="button" value="Cancel" style="width:60px">
+ </td>
+ </tr>
+
+</table>
+
+<input name="MARKERCOLOR" type="hidden" id="markerColor" value="FF0000">
+<input name="LINECOLOR" type="hidden" id="lineColor" value="0000FF">
+<input name="FILLFORECOLOR" type="hidden" id="fillForeColor" value="00FF00">
+<input name="FILLBACKCOLOR" type="hidden" id="fillBackColor" value="00FF00">
+<input name="FILLBACKTRANS" type="hidden" id="fillBackTrans" value="true">
+<input name="BORDERCOLOR" type="hidden" id="borderColor" value="000000">
+<input name="LABELFORECOLOR" type="hidden" id="labelForeColor" value="000000">
+<input name="LABELBACKCOLOR" type="hidden" id="labelBackColor" value="FFFFFF">
+
+</form>
+
+<?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>
Added: trunk/widgets/Redline/templates/markuplayerdefinition.xml
===================================================================
--- trunk/widgets/Redline/templates/markuplayerdefinition.xml (rev 0)
+++ trunk/widgets/Redline/templates/markuplayerdefinition.xml 2011-06-25 15:31:14 UTC (rev 2407)
@@ -0,0 +1,124 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<LayerDefinition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:noNamespaceSchemaLocation="LayerDefinition-1.0.0.xsd" version="1.0.0">
+ <VectorLayerDefinition>
+ <ResourceId>%s</ResourceId>
+ <FeatureName>MarkupSchema:Markup</FeatureName>
+ <FeatureNameType>FeatureClass</FeatureNameType>
+ <PropertyMapping>
+ <Name>Text</Name>
+ <Value>Text</Value>
+ </PropertyMapping>
+ <Geometry>Geometry</Geometry>
+ <VectorScaleRange>
+ <PointTypeStyle>
+ <DisplayAsText>false</DisplayAsText>
+ <AllowOverpost>false</AllowOverpost>
+ <PointRule>
+ <LegendLabel></LegendLabel>
+ <Label>
+ <Unit>%s</Unit>
+ <SizeContext>DeviceUnits</SizeContext>
+ <SizeX>%s</SizeX>
+ <SizeY>%s</SizeY>
+ <Rotation>0</Rotation>
+ <Text>"Text"</Text>
+ <FontName>Arial</FontName>
+ <ForegroundColor>%s</ForegroundColor>
+ <BackgroundColor>%s</BackgroundColor>
+ <BackgroundStyle>%s</BackgroundStyle>
+ <HorizontalAlignment>'Center'</HorizontalAlignment>
+ <VerticalAlignment>'Baseline'</VerticalAlignment>
+ <Bold>%s</Bold>
+ <Italic>%s</Italic>
+ <Underlined>%s</Underlined>
+ </Label>
+ <PointSymbolization2D>
+ <Mark>
+ <Unit>%s</Unit>
+ <SizeContext>DeviceUnits</SizeContext>
+ <SizeX>%s</SizeX>
+ <SizeY>%s</SizeY>
+ <Rotation>0</Rotation>
+ <Shape>%s</Shape>
+ <Fill>
+ <FillPattern>Solid</FillPattern>
+ <ForegroundColor>%s</ForegroundColor>
+ <BackgroundColor>FFFFFFFF</BackgroundColor>
+ </Fill>
+ <Edge>
+ <LineStyle>Solid</LineStyle>
+ <Thickness>0.0</Thickness>
+ <Color>%s</Color>
+ <Unit>Centimeters</Unit>
+ </Edge>
+ </Mark>
+ </PointSymbolization2D>
+ </PointRule>
+ </PointTypeStyle>
+ <LineTypeStyle>
+ <LineRule>
+ <LegendLabel></LegendLabel>
+ <Label>
+ <Unit>%s</Unit>
+ <SizeContext>DeviceUnits</SizeContext>
+ <SizeX>%s</SizeX>
+ <SizeY>%s</SizeY>
+ <Rotation>0</Rotation>
+ <Text>"Text"</Text>
+ <FontName>Arial</FontName>
+ <ForegroundColor>%s</ForegroundColor>
+ <BackgroundColor>%s</BackgroundColor>
+ <BackgroundStyle>%s</BackgroundStyle>
+ <HorizontalAlignment>'Center'</HorizontalAlignment>
+ <VerticalAlignment>'Baseline'</VerticalAlignment>
+ <Bold>%s</Bold>
+ <Italic>%s</Italic>
+ <Underlined>%s</Underlined>
+ </Label>
+ <LineSymbolization2D>
+ <LineStyle>%s</LineStyle>
+ <Thickness>%s</Thickness>
+ <Color>%s</Color>
+ <Unit>%s</Unit>
+ </LineSymbolization2D>
+ </LineRule>
+ </LineTypeStyle>
+ <AreaTypeStyle>
+ <AreaRule>
+ <LegendLabel></LegendLabel>
+ <Label>
+ <Unit>%s</Unit>
+ <SizeContext>DeviceUnits</SizeContext>
+ <SizeX>%s</SizeX>
+ <SizeY>%s</SizeY>
+ <Rotation>0</Rotation>
+ <Text>"Text"</Text>
+ <FontName>Arial</FontName>
+ <ForegroundColor>%s</ForegroundColor>
+ <BackgroundColor>%s</BackgroundColor>
+ <BackgroundStyle>%s</BackgroundStyle>
+ <HorizontalAlignment>'Center'</HorizontalAlignment>
+ <VerticalAlignment>Halfline</VerticalAlignment>
+ <Bold>%s</Bold>
+ <Italic>%s</Italic>
+ <Underlined>%s</Underlined>
+ </Label>
+ <AreaSymbolization2D>
+ <Fill>
+ <FillPattern>%s</FillPattern>
+ <ForegroundColor>%s</ForegroundColor>
+ <BackgroundColor>%s</BackgroundColor>
+ </Fill>
+ <Stroke>
+ <LineStyle>%s</LineStyle>
+ <Thickness>%s</Thickness>
+ <Color>%s</Color>
+ <Unit>%s</Unit>
+ </Stroke>
+ </AreaSymbolization2D>
+ </AreaRule>
+ </AreaTypeStyle>
+ </VectorScaleRange>
+ </VectorLayerDefinition>
+</LayerDefinition>
Modified: trunk/widgets/Redline.js
===================================================================
--- trunk/widgets/Redline.js 2011-06-23 10:15:24 UTC (rev 2406)
+++ trunk/widgets/Redline.js 2011-06-25 15:31:14 UTC (rev 2407)
@@ -45,40 +45,9 @@
// a reference to a redline taskPane
taskPane: null,
- // array of OL vector layer
- vectorLayers: null,
-
- // the default layer name
- defaultLayerName: null,
-
- // the drawing controls
- drawControls: null,
-
- // The default feature style: to be changed
- defaultFeatureStyle: new OpenLayers.Style({
- pointRadius: 4,
- graphicName: "square",
- fillColor: "#55ff4e",
- fillOpacity: 0.4,
- strokeWidth: 2,
- strokeOpacity: 1,
- strokeColor: "#666666"
- }),
-
- // the default feature styleMap
- styleMap: null,
-
- activeControl: null,
- activeLayer: null,
-
- // the hidden html form for the save action
- saveForm: null,
-
initializeWidget: function(widgetTag) {
- var json = widgetTag.extension;
- this.mapWidget = Fusion.getWidgetById('Map');
-
- this.defaultLayerName = OpenLayers.i18n('redlineLayerName');
+ var json = widgetTag.extension;
+ this.mapWidget = Fusion.getWidgetById('Map');
// register Redline specific events
this.registerEventID(Fusion.Event.REDLINE_FEATURE_ADDED);
@@ -86,238 +55,27 @@
this.sTarget = json.Target ? json.Target[0] : "";
if (this.sTarget)
this.taskPane = new Fusion.Widget.Redline.DefaultTaskPane(this, widgetTag.location);
-
- // Check in the user has defined his default feature style
- var defaultFeatureStyle;
- var jsonFeatureStyle = json.FeatureStyle ? json.FeatureStyle[0] : null;
- if (jsonFeatureStyle && (typeof(jsonFeatureStyle) == "object"))
- {
- defaultFeatureStyle = new OpenLayers.Style();
- for(var styleProperty in jsonFeatureStyle) {
- eval("defaultFeatureStyle.defaultStyle."+styleProperty+" = \""+jsonFeatureStyle[styleProperty][0]+"\";");
- }
- } else {
- defaultFeatureStyle = this.defaultFeatureStyle
- }
-
- this.styleMap = new OpenLayers.StyleMap(defaultFeatureStyle);
-
- // create one default layer, unless other redline widgets have created it
- this.vectorLayers = this.mapWidget.oMapOL.getLayersByName(this.defaultLayerName + '0');
-
- if (!this.vectorLayers.length) {
- this.vectorLayers[0] = new OpenLayers.Layer.Vector(this.defaultLayerName + '0', { styleMap: this.styleMap });
- this.vectorLayers[0].redLineLayer = true;
- this.mapWidget.oMapOL.addLayers([this.vectorLayers[0]]);
- }
-
- this.createDrawControls();
-
- // Check if the default control is specified
- this.defaultControl = 'point';
- if (json.DefaultControl) {
- var control = json.DefaultControl[0].toLowerCase();
- if (this.drawControls[control])
- this.defaultControl = control;
- }
-
- this.createSaveForm();
},
-
- createDrawControls: function() {
- this.drawControls = {
- point: new OpenLayers.Control.DrawFeature(this.vectorLayers[0],
- OpenLayers.Handler.Point, {
- handlerOptions: {
- layerOptions: {
- styleMap: this.styleMap
- }
- }
- }),
- line: new OpenLayers.Control.DrawFeature(this.vectorLayers[0],
- OpenLayers.Handler.Path, {
- handlerOptions: {
- freehandToggle: null,
- freehand: false,
- style: "default", // this forces default render intent
- layerOptions: {
- styleMap: this.styleMap
- }
- }
- }),
- rectangle: new OpenLayers.Control.DrawFeature(this.vectorLayers[0],
- OpenLayers.Handler.RegularPolygon, {
- handlerOptions: {
- sides: 4,
- irregular: true,
- style: "default", // this forces default render intent
- layerOptions: {
- styleMap: this.styleMap
- }
- }
- }),
- polygon: new OpenLayers.Control.DrawFeature(this.vectorLayers[0],
- OpenLayers.Handler.Polygon, {
- handlerOptions: {
- freehand: false,
- style: "default", // this forces default render intent
- layerOptions: {
- styleMap: this.styleMap
- }
- }
- })
- };
-
- for(var key in this.drawControls) {
- this.drawControls[key].events.register('featureadded', this, this.featureAdded);
- this.mapWidget.oMapOL.addControl(this.drawControls[key]);
- }
-
+
+ getSessionID: function() {
+ return this.getMapLayer().getSessionID();
},
-
- createSaveForm: function(panelDocument) {
- /* Create a hidden form for the Save action */
- var sl = Fusion.getScriptLanguage();
- var scriptURL = Fusion.getFusionURL() + 'layers/Generic/' + sl + '/save.' + sl;
- var div = document.createElement("div");
- var type = document.createElement("input");
- var content = document.createElement("input");
- var name = document.createElement("input");
- var submit = document.createElement("input");
-
- div.style.display = "none";
- this.saveForm = document.createElement("form");
- submit.type="submit";
- submit.name="submit_element";
- submit.value="submit";
- this.saveForm.method = "POST";
- this.saveForm.action = scriptURL;
- type.type = "text";
- type.name = "type";
- type.value = 'text/xml';
- content.type = "text";
- content.name = "content";
- name.type = "text";
- name.name = "name";
- this.saveForm.appendChild(type);
- this.saveForm.appendChild(content);
- this.saveForm.appendChild(name);
- this.saveForm.appendChild(submit);
- div.appendChild(this.saveForm);
- document.body.appendChild(div);
+
+ getMapName: function() {
+ var maps = this.mapWidget.getAllMaps();
+ //Last one is top-most
+ return maps[maps.length - 1].getMapName();
},
-
+
// activate the redline widget
activate: function() {
if (this.taskPane) {
this.taskPane.loadDisplayPanel();
}
- this.activateLayer(0);
- this.activateControl(this.defaultControl,0);
- this.getMap().supressContextMenu(true);
},
// desactivate the redline widget
deactivate: function() {
- this.activeControl.deactivate();
- this.activeControl = null;
- this.getMap().supressContextMenu(false);
- },
-
- featureAdded: function(evt) {
- this.triggerEvent(Fusion.Event.REDLINE_FEATURE_ADDED, evt.feature);
- this.moveLayerToTop(evt.feature.layer);
- },
-
- // move the redline layer to the top and redraw it
- moveLayerToTop: function(layer) {
- var map = layer.map;
- var baseIndex = map.getLayerIndex(layer);
-
- if(baseIndex != layer.map.layers.length-2)
- {
- // except for the current temp drawing layer, the redline layer is not on the top of the map.
- map.setLayerIndex(layer,layer.map.layers.length-2)
- }
- layer.redraw();
- },
-
- // change active layer
- activateLayer: function(layerIndex) {
- this.activeLayer = this.vectorLayers[layerIndex];
- for(var key in this.drawControls) {
- this.drawControls[key].layer = this.vectorLayers[layerIndex];
- }
- },
-
- // change active control
- activateControl: function(type) {
- if (this.activeControl)
- this.activeControl.deactivate();
-
- var control = this.drawControls[type];
- this.activeControl = control;
- control.activate();
- },
-
- exportToGML: function() {
- var gmlParser = new OpenLayers.Format.GML();
- var fileContent = gmlParser.write(this.activeLayer.features);
- this.saveForm.elements[0].value = "text/xml";
- this.saveForm.elements[1].value = escape(fileContent);
- this.saveForm.elements[2].value = this.activeLayer.name + '.gml';
- this.saveForm.submit();
- },
-
- newLayer: function(layerName) {
- var i = this.vectorLayers.length;
- this.vectorLayers[i] = new OpenLayers.Layer.Vector(layerName, {styleMap: this.styleMap});
- this.vectorLayers[i].redLineLayer = true;
- this.mapWidget.oMapOL.addLayer(this.vectorLayers[i]);
- },
-
- newLayerFromFile: function(fileName) {
- var i = this.vectorLayers.length;
- this.vectorLayers[i] = new OpenLayers.Layer.Vector(this.defaultLayerName + this.vectorLayers.length, {
- strategies: [new OpenLayers.Strategy.Fixed()],
- protocol: new OpenLayers.Protocol.HTTP({
- url: Fusion.getFusionURL() +"widgets/Redline/Redline.php?"+"file="+fileName,
- format: new OpenLayers.Format.GML()
- }),
- styleMap: this.styleMap
- });
- this.vectorLayers[i].redLineLayer = true;
- this.mapWidget.oMapOL.addLayer(this.vectorLayers[i]);
- },
-
- removeLayer: function(layerIndex) {
- this.vectorLayers[layerIndex].destroyFeatures();
- this.vectorLayers[layerIndex].destroy();
- this.vectorLayers.splice(layerIndex,1);
- // we always keep at least one vector layer
- if (this.vectorLayers.length == 0) {
- this.vectorLayers[0] = new OpenLayers.Layer.Vector(this.defaultLayerName + '0', { styleMap: this.styleMap });
- this.mapWidget.oMapOL.addLayers([this.vectorLayers[0]]);
- this.vectorLayers[0].redLineLayer = true;
- }
- this.activateLayer(0);
- },
-
- getUniqueLayerName: function() {
- var offset = this.vectorLayers.length;
- var exist = true;
- while (exist) {
- exist = false;
- var i = 0;
- while (!exist && i < this.vectorLayers.length) {
- if ((this.defaultLayerName + offset) == this.vectorLayers[i].name)
- exist = true;
- i++;
- }
- if (exist)
- offset++;
- }
- return this.defaultLayerName + offset;
}
});
@@ -331,31 +89,29 @@
taskPaneWin: null,
// the panel url
- panelUrl: 'widgets/Redline/Redline.php',
- // the panel CSS
- panelCss: 'Redline/Redline.css',
+ panelUrl: 'widgets/Redline/markupmain.php',
initialize: function(widget,widgetLocation) {
this.widget = widget;
this.widget.registerForEvent(Fusion.Event.REDLINE_FEATURE_ADDED, OpenLayers.Function.bind(this.featureAdded, this));
- Fusion.addWidgetStyleSheet(widgetLocation + this.panelCss);
},
loadDisplayPanel: function() {
var url = Fusion.getFusionURL() + this.panelUrl;
+ var params = [];
- var params = [];
-
- // Add any additional params here
- params.push('LOCALE='+Fusion.locale);
-
- if (url.indexOf('?') < 0) {
- url += '?';
- } else if (url.slice(-1) != '&') {
- url += '&';
- }
- url += params.join('&');
-
+ // Add any additional params here
+ params.push('LOCALE='+Fusion.locale);
+ params.push('MAPNAME='+this.widget.getMapName());
+ params.push('SESSION='+this.widget.getSessionID());
+
+ if (url.indexOf('?') < 0) {
+ url += '?';
+ } else if (url.slice(-1) != '&') {
+ url += '&';
+ }
+ url += params.join('&');
+
var taskPaneTarget = Fusion.getWidgetById(this.widget.sTarget);
var outputWin = window;
@@ -367,180 +123,5 @@
}
//outputWin.parent = window;
this.taskPaneWin = outputWin;
- var initFunction = OpenLayers.Function.bind(this.initPanel, this);
- setTimeout(initFunction,300);
- },
-
- // when the panel is loaded....
- initPanel: function() {
- if (!this.taskPaneWin.document.getElementById("panelIsLoaded")) {
- var initFunction = OpenLayers.Function.bind(this.initPanel, this);
- setTimeout(initFunction,300);
- return;
- }
-
- // select the default control
- var radioName = this.widget.defaultControl.charAt(0).toUpperCase() + this.widget.defaultControl.substr(1);
- this.taskPaneWin.document.getElementById("RedlineWidget"+radioName+"Radio").checked = true;
-
- // do we have an uploaded file ?
- if (this.taskPaneWin.document.getElementById("uploadedFileName")) {
- this.widget.activateControl(this.widget.defaultControl,0); //hack to reset the right control/radio
- this.widget.newLayerFromFile(this.taskPaneWin.document.getElementById("uploadedFileName").getAttribute("value"));
- }
- this.bindEvents();
- this.updateLayerList();
- this.updateFeatureList();
- },
-
- bindEvents: function() {
- var doc = this.taskPaneWin.document;
-
- // layers
- doc.getElementById("RedlineWidgetLayerList").onchange = OpenLayers.Function.bind(this.selectLayer, this);
- doc.getElementById("RedlineWidgetNewLayerButton").onclick = OpenLayers.Function.bind(this.newLayer, this);
- doc.getElementById("RedlineWidgetRenameLayerButton").onclick = OpenLayers.Function.bind(this.renameLayer, this);
- doc.getElementById("RedlineWidgetRemoveLayerButton").onclick = OpenLayers.Function.bind(this.removeLayer, this);
- doc.getElementById("RedlineWidgetSaveButton").onclick = OpenLayers.Function.bind(this.saveLayer, this);
- doc.getElementById("RedlineWidgetUploadButton").onclick = OpenLayers.Function.bind(this.uploadFile, this);
- // Controls
- doc.getElementById("RedlineWidgetPointRadio").onclick = OpenLayers.Function.bind(this.widget.activateControl, this.widget, 'point');
- doc.getElementById("RedlineWidgetLineRadio").onclick = OpenLayers.Function.bind(this.widget.activateControl, this.widget, 'line');
- doc.getElementById("RedlineWidgetRectangleRadio").onclick = OpenLayers.Function.bind(this.widget.activateControl, this.widget, 'rectangle');
- doc.getElementById("RedlineWidgetPolygonRadio").onclick = OpenLayers.Function.bind(this.widget.activateControl, this.widget, 'polygon');
- // features
- doc.getElementById("RedlineWidgetRemoveFeatureButton").onclick = OpenLayers.Function.bind(this.removeFeature, this);
- doc.getElementById("RedlineWidgetRenameFeatureButton").onclick = OpenLayers.Function.bind(this.renameFeature, this);
- },
-
- newLayer: function() {
- var name = prompt("Layer name:", this.widget.getUniqueLayerName());
- if (name!=null && name!="") {
- this.widget.newLayer(name);
- this.updateLayerList();
- }
- },
-
- removeLayer: function() {
- var i = this.taskPaneWin.document.getElementById("RedlineWidgetLayerList").selectedIndex;
- this.widget.removeLayer(i);
- this.updateLayerList();
- this.updateFeatureList();
- },
-
- renameLayer: function() {
- var name = prompt("Layer name:", "");
- if (name!=null && name!="") {
- var i = this.taskPaneWin.document.getElementById("RedlineWidgetLayerList").selectedIndex;
- this.widget.vectorLayers[i].name = name;
- this.updateLayerList();
- }
- },
-
- selectLayer: function() {
- var i = this.taskPaneWin.document.getElementById("RedlineWidgetLayerList").selectedIndex;
- this.widget.activateLayer(i);
- this.updateFeatureList();
- },
-
- saveLayer: function() {
- this.widget.exportToGML();
- },
-
- uploadFile: function() {
- var initFunction = OpenLayers.Function.bind(this.initPanel, this);
- setTimeout(initFunction,300);
- },
-
- updateLayerList: function() {
- var select = this.taskPaneWin.document.getElementById('RedlineWidgetLayerList');
- var selectedIndex = select.selectedIndex;
- select.length = 0;
- var olMap = this.widget.mapWidget.oMapOL;
- var numLayers = olMap.getNumLayers();
- this.widget.vectorLayers = [];
- for (var i=0; i < numLayers; i++) {
- if (olMap.layers[i].redLineLayer) {
- this.widget.vectorLayers.push(olMap.layers[i]);
- }
- };
-
- for ( var i = 0; i < this.widget.vectorLayers.length;i++)
- {
- var opt = document.createElement('option');
- opt.text = this.widget.vectorLayers[i].name;
- if (i == selectedIndex)
- opt.selected = true;
- try
- {
- select.add(opt,null); // standards compliant
- }
- catch(ex)
- {
- select.add(opt); // IE only
- }
- }
- },
-
- featureAdded: function(eventID, feature) {
- var select = this.taskPaneWin.document.getElementById('RedlineWidgetFeatureList');
- var opt = document.createElement('option');
- opt.text = feature.id;
- try
- {
- select.add(opt,null); // standards compliant
- }
- catch(ex)
- {
- select.add(opt); // IE only
- }
- },
-
- removeFeature: function() {
- var select = this.taskPaneWin.document.getElementById('RedlineWidgetFeatureList');
- var i = select.selectedIndex;
- if (i != -1) {
- this.widget.activeLayer.destroyFeatures([this.widget.activeLayer.features[i]]);
- select.remove(i);
- }
- },
-
- renameFeature: function() {
- var select = this.taskPaneWin.document.getElementById('RedlineWidgetFeatureList');
- var i = select.selectedIndex;
- if (i != -1) {
- var name = prompt("Feature name:", "");
- if (name!=null && name!="") {
- this.widget.activeLayer.features[i].id = name;
- select.options[i].text = name;
- }
- }
- },
-
- updateFeatureList: function() {
- var select = this.taskPaneWin.document.getElementById('RedlineWidgetFeatureList');
- var selectedIndex = select.selectedIndex;
- select.length = 0;
- for ( var i = 0; i < this.widget.activeLayer.features.length; i++)
- {
- var opt = document.createElement('option');
- opt.text = this.widget.activeLayer.features[i].id;
- try
- {
- select.add(opt,null); // standards compliant
- }
- catch(ex)
- {
- select.add(opt); // IE only
- }
- }
- },
-
- clearFeatureList: function() {
- var select = this.taskPaneWin.document.getElementById('RedlineWidgetFeatureList');
- for (var i = (select.options.length-1); i>=0; i--) {
- select.options[i] = null;
}
- select.selectedIndex = -1;
- }
});
More information about the fusion-commits
mailing list