[mapguide-commits] r5590 - in
branches/2.2/MgDev/Doc/samples/phpsamples: .
analyzing_features common digitizing_features
modifying_maps_and_layers working_with_feature_data
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Thu Mar 3 10:43:04 EST 2011
Author: jng
Date: 2011-03-03 07:43:04 -0800 (Thu, 03 Mar 2011)
New Revision: 5590
Modified:
branches/2.2/MgDev/Doc/samples/phpsamples/
branches/2.2/MgDev/Doc/samples/phpsamples/analyzing_features/createbuffer.php
branches/2.2/MgDev/Doc/samples/phpsamples/analyzing_features/selectfeaturesinbuffer.php
branches/2.2/MgDev/Doc/samples/phpsamples/analyzing_features/task_pane.php
branches/2.2/MgDev/Doc/samples/phpsamples/common/common.php
branches/2.2/MgDev/Doc/samples/phpsamples/digitizing_features/draw_line.php
branches/2.2/MgDev/Doc/samples/phpsamples/main.php
branches/2.2/MgDev/Doc/samples/phpsamples/modifying_maps_and_layers/RecentlyBuilt.LayerDefinition
branches/2.2/MgDev/Doc/samples/phpsamples/modifying_maps_and_layers/create_new_point_layer_definition.php
branches/2.2/MgDev/Doc/samples/phpsamples/modifying_maps_and_layers/layer_functions.php
branches/2.2/MgDev/Doc/samples/phpsamples/working_with_feature_data/task_pane.php
Log:
#1614: Merge trunk changes to 2.2
Property changes on: branches/2.2/MgDev/Doc/samples/phpsamples
___________________________________________________________________
Added: svn:mergeinfo
+ /trunk/MgDev/Doc/samples/phpsamples:5584-5588
Modified: branches/2.2/MgDev/Doc/samples/phpsamples/analyzing_features/createbuffer.php
===================================================================
--- branches/2.2/MgDev/Doc/samples/phpsamples/analyzing_features/createbuffer.php 2011-03-03 15:10:47 UTC (rev 5589)
+++ branches/2.2/MgDev/Doc/samples/phpsamples/analyzing_features/createbuffer.php 2011-03-03 15:43:04 UTC (rev 5590)
@@ -16,6 +16,12 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-->
+<!--
+This sample has been updated to reflect simplified usage patterns enabled by convenience APIs
+introduced in MapGuide OS 2.0 by allowing you to query and insert features directly from
+the MgLayer objects themselves and the ability to get a MgFeatureReader directly from the MgSelection
+object.
+-->
<head>
<title>Viewer Sample Application - Create Buffer</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
@@ -58,8 +64,8 @@
$featureService = $siteConnection->CreateService(MgServiceType::FeatureService);
$queryOptions = new MgFeatureQueryOptions();
- $map = new MgMap();
- $map->Open($resourceService, $mapName);
+ $map = new MgMap($siteConnection);
+ $map->Open($mapName);
// Check for selection data passed via HTTP POST
@@ -85,13 +91,15 @@
$wktReaderWriter = new MgWktReaderWriter();
$coordinateSystemFactory = new MgCoordinateSystemFactory();
$srs = $coordinateSystemFactory->Create($mapWktSrs);
- $srsMeasure = new MgCoordinateSystemMeasure($srs);
+ $srsMeasure = $srs->GetMeasure();
// Check for a buffer layer. If it exists, delete
// the current features.
// If it does not exist, create a feature source and
// a layer to hold the buffer.
+ /*
+ // Old way, pre MapGuide OS 2.0. Kept here for reference
try
{
$bufferLayer = $map->GetLayers()->GetItem('Buffer');
@@ -112,7 +120,28 @@
$bufferLayer = CreateBufferLayer($resourceService, $bufferFeatureResId, $sessionId);
$map->GetLayers()->Insert(0, $bufferLayer);
}
+ */
+ // New way, post MapGuide 2.0
+ $layerIndex = $map->GetLayers()->IndexOf('Buffer');
+ if ($layerIndex < 0)
+ {
+ // The layer does not exist and must be created.
+
+ $bufferFeatureResId = new MgResourceIdentifier("Session:" . $sessionId . "//Buffer.FeatureSource");
+ CreateBufferFeatureSource($featureService, $mapWktSrs, $bufferFeatureResId);
+ $bufferLayer = CreateBufferLayer($resourceService, $bufferFeatureResId, $sessionId);
+ $map->GetLayers()->Insert(0, $bufferLayer);
+ }
+ else
+ {
+ $bufferLayer = $map->GetLayers()->GetItem($layerIndex);
+ $commands = new MgFeatureCommandCollection();
+ $commands->Add(new MgDeleteFeatures('BufferClass', "ID like '%'"));
+
+ $bufferLayer->UpdateFeatures($commands);
+ }
+
for ($i = 0; $i < $selectedLayers->GetCount(); $i++)
{
// Only check selected features in the Parcels layer.
@@ -121,7 +150,8 @@
if ($layer->GetName() == 'Parcels')
{
-
+ // Old way, pre MapGuide OS 2.0. Kept here for reference
+ /*
// Create a filter containing the IDs of the selected features on this layer
$layerClassName = $layer->GetFeatureClassName();
@@ -131,13 +161,13 @@
$layerFeatureId = $layer->GetFeatureSourceId();
$layerFeatureResource = new MgResourceIdentifier($layerFeatureId);
-
+
// Apply the filter to the feature resource for the selected layer. This returns
// an MgFeatureReader of all the selected features.
$queryOptions->SetFilter($selectionString);
$featureReader = $featureService->SelectFeatures($layerFeatureResource, $layerClassName, $queryOptions);
-
+
// Process each item in the MgFeatureReader. Get the
// geometries from all the selected features and
// merge them into a single geometry.
@@ -175,12 +205,65 @@
}
$results = $featureService->UpdateFeatures($bufferFeatureResId, $commands, false);
-
+
$bufferLayer->SetVisible(true);
$bufferLayer->ForceRefresh();
$bufferLayer->SetDisplayInLegend(true);
$map->Save($resourceService);
+ */
+
+ // New way, post MapGuide 2.0
+
+ // Get the selected features from the MgSelection object
+ $featureReader = $selection->GetSelectedFeatures($layer, $layer->GetFeatureClassName(), false);
+
+ // Process each item in the MgFeatureReader. Get the
+ // geometries from all the selected features and
+ // merge them into a single geometry.
+ $inputGeometries = new MgGeometryCollection();
+ while ($featureReader->ReadNext())
+ {
+ $featureGeometryData = $featureReader->GetGeometry('SHPGEOM');
+ $featureGeometry = $agfReaderWriter->Read($featureGeometryData);
+
+ $inputGeometries->Add($featureGeometry);
+ }
+
+ $geometryFactory = new MgGeometryFactory();
+ $mergedGeometries = $geometryFactory->CreateMultiGeometry($inputGeometries);
+
+ // Add buffer features to the temporary feature source.
+ // Create multiple concentric buffers to show area.
+ // If the stylization for the layer draws the features
+ // partially transparent, the concentric rings will be
+ // progressively darker towards the center.
+ // The stylization is set in the layer template file, which
+ // is used in function CreateBufferLayer().
+
+ $commands = new MgFeatureCommandCollection();
+ for ($bufferRing = 0; $bufferRing < $bufferRingCount; $bufferRing++)
+ {
+ $bufferDist = $srs->ConvertMetersToCoordinateSystemUnits($bufferRingSize * ($bufferRing + 1));
+ $bufferGeometry = $mergedGeometries->Buffer($bufferDist, $srsMeasure);
+
+ $properties = new MgPropertyCollection();
+ $properties->Add(new MgGeometryProperty('BufferGeometry', $agfReaderWriter->Write($bufferGeometry)));
+
+ $commands->Add(new MgInsertFeatures('BufferClass', $properties));
+ }
+
+ // Old way, pre MapGuide OS 2.0
+ //$featureService->UpdateFeatures($bufferFeatureResId, $commands, false);
+
+ // New way, post MapGuide OS 2.0
+ $bufferLayer->UpdateFeatures($commands);
+
+ $bufferLayer->SetVisible(true);
+ $bufferLayer->ForceRefresh();
+ $bufferLayer->SetDisplayInLegend(true);
+ $map->Save();
+
}
}
}
Modified: branches/2.2/MgDev/Doc/samples/phpsamples/analyzing_features/selectfeaturesinbuffer.php
===================================================================
--- branches/2.2/MgDev/Doc/samples/phpsamples/analyzing_features/selectfeaturesinbuffer.php 2011-03-03 15:10:47 UTC (rev 5589)
+++ branches/2.2/MgDev/Doc/samples/phpsamples/analyzing_features/selectfeaturesinbuffer.php 2011-03-03 15:43:04 UTC (rev 5590)
@@ -15,6 +15,13 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-->
+
+<!--
+This sample has been updated to reflect simplified usage patterns enabled by convenience APIs
+introduced in MapGuide OS 2.0 by allowing you to query and insert features directly from
+the MgLayer objects themselves and the ability to get a MgFeatureReader directly from the MgSelection
+object.
+-->
<html>
<head>
@@ -58,8 +65,8 @@
$featureService = $siteConnection->CreateService(MgServiceType::FeatureService);
$queryOptions = new MgFeatureQueryOptions();
- $map = new MgMap();
- $map->Open($resourceService, $mapName);
+ $map = new MgMap($siteConnection);
+ $map->Open($mapName);
// Check for selection data passed via HTTP POST
@@ -84,13 +91,15 @@
$wktReaderWriter = new MgWktReaderWriter();
$coordinateSystemFactory = new MgCoordinateSystemFactory();
$srs = $coordinateSystemFactory->Create($mapWktSrs);
- $srsMeasure = new MgCoordinateSystemMeasure($srs);
+ $srsMeasure = $srs->GetMeasure();
// Check for a buffer layer. If it exists, delete
// the current features.
// If it does not exist, create a feature source and
// a layer to hold the buffer.
+ /*
+ // Old way, pre MapGuide OS 2.0. Kept here for reference
try
{
$bufferLayer = $map->GetLayers()->GetItem('Buffer');
@@ -111,12 +120,35 @@
$bufferLayer = CreateBufferLayer($resourceService, $bufferFeatureResId, $sessionId);
$map->GetLayers()->Insert(0, $bufferLayer);
}
+ */
+
+ // This is how things can be done now
+ $layerIndex = $map->GetLayers()->IndexOf('Buffer');
+ if ($layerIndex < 0)
+ {
+ // The layer does not exist and must be created.
+ $bufferFeatureResId = new MgResourceIdentifier("Session:" . $sessionId . "//Buffer.FeatureSource");
+ CreateBufferFeatureSource($featureService, $mapWktSrs, $bufferFeatureResId);
+ $bufferLayer = CreateBufferLayer($resourceService, $bufferFeatureResId, $sessionId);
+ $map->GetLayers()->Insert(0, $bufferLayer);
+ }
+ else
+ {
+ $bufferLayer = $map->GetLayers()->GetItem($layerIndex);
+ $commands = new MgFeatureCommandCollection();
+ $commands->Add(new MgDeleteFeatures('BufferClass', "ID like '%'"));
+
+ $bufferLayer->UpdateFeatures($commands);
+ }
+
// Check for a parcel marker layer. If it exists, delete
// the current features.
// If it does not exist, create a feature source and
// a layer to hold the parcel markers.
+ /*
+ // Old way, pre MapGuide OS 2.0. Kept here for reference
try
{
$parcelMarkerLayer = $map->GetLayers()->GetItem('ParcelMarker');
@@ -137,6 +169,25 @@
$parcelMarkerLayer = CreateParcelMarkerLayer($resourceService, $parcelFeatureResId, $sessionId);
$map->GetLayers()->Insert(0, $parcelMarkerLayer);
}
+ */
+
+ // New way, post MapGuide 2.0
+ $layerIndex = $map->GetLayers()->IndexOf('ParcelMarker');
+ if ($layerIndex < 0)
+ {
+ $parcelFeatureResId = new MgResourceIdentifier("Session:" . $sessionId . "//ParcelMarker.FeatureSource");
+ CreateParcelMarkerFeatureSource($featureService, $mapWktSrs, $parcelFeatureResId);
+ $parcelMarkerLayer = CreateParcelMarkerLayer($resourceService, $parcelFeatureResId, $sessionId);
+ $map->GetLayers()->Insert(0, $parcelMarkerLayer);
+ }
+ else
+ {
+ $parcelMarkerLayer = $map->GetLayers()->GetItem($layerIndex);
+ $commands = new MgFeatureCommandCollection();
+ $commands->Add(new MgDeleteFeatures('ParcelMarkerClass', "ID like '%'"));
+
+ $parcelMarkerLayer->UpdateFeatures($commands);
+ }
// Check each layer in the selection.
@@ -151,6 +202,9 @@
echo 'Marking all parcels inside the buffer that are of type "MFG"';
+ /*
+ // Old way, pre MapGuide OS 2.0. Kept here for reference
+
// Create a filter containing the IDs of the selected features on this layer
$layerClassName = $layer->GetFeatureClassName();
@@ -166,7 +220,13 @@
$queryOptions->SetFilter($selectionString);
$featureReader = $featureService->SelectFeatures($layerFeatureResource, $layerClassName, $queryOptions);
-
+ */
+
+ // New way, post MapGuide 2.0
+
+ $featureReader = $selection->GetSelectedFeatures($layer, $layer->GetFeatureClassName(), false);
+
+
// Process each item in the MgFeatureReader. Get the
// geometries from all the selected features and
// merge them into a single geometry.
@@ -196,42 +256,47 @@
$queryOptions->SetFilter("RTYPE = 'MFG'");
$queryOptions->SetSpatialFilter('SHPGEOM', $bufferGeometry, MgFeatureSpatialOperations::Inside);
+ /*
+ // Old way, pre MapGuide OS 2.0. Kept here for reference
+ $featureResId = new MgResourceIdentifier("Library://Samples/Sheboygan/Data/Parcels.FeatureSource");
+ $featureReader = $featureService->SelectFeatures($featureResId, "Parcels", $queryOptions);
+ */
+
+ // New way, post MapGuide OS 2.0
+ $featureReader = $layer->SelectFeatures($queryOptions);
+
// Get the features from the feature source,
// determine the centroid of each selected feature, and
// add a point to the ParcelMarker layer to mark the
// centroid.
// Collect all the points into an MgFeatureCommandCollection,
// so they can all be added in one operation.
-
- $featureResId = new MgResourceIdentifier("Library://Samples/Sheboygan/Data/Parcels.FeatureSource");
- $featureReader = $featureService->SelectFeatures($featureResId, "Parcels", $queryOptions);
-
+
$parcelMarkerCommands = new MgFeatureCommandCollection();
while ($featureReader->ReadNext())
{
-
$byteReader = $featureReader->GetGeometry('SHPGEOM');
-
$geometry = $agfReaderWriter->Read($byteReader);
$point = $geometry->GetCentroid();
// Create an insert command for this parcel.
-
$properties = new MgPropertyCollection();
-
$properties->Add(new MgGeometryProperty('ParcelLocation', $agfReaderWriter->Write($point)));
$parcelMarkerCommands->Add(new MgInsertFeatures('ParcelMarkerClass', $properties));
-
}
$featureReader->Close();
if ($parcelMarkerCommands->GetCount() > 0)
{
- $featureService->UpdateFeatures($parcelFeatureResId, $parcelMarkerCommands, false);
+ // Old way, pre MapGuide OS 2.0. Kept here for reference
+ //$featureService->UpdateFeatures($parcelFeatureResId, $parcelMarkerCommands, false);
+
+ // New way, post MapGuide OS 2.0
+ $parcelMarkerLayer->UpdateFeatures($parcelMarkerCommands);
}
else
{
- echo '</p><p>No parcels within the buffer area match.';
+ echo '</p><p>No parcels within the buffer area match.';
}
// Create a feature in the buffer feature source to show the area covered by the buffer.
@@ -242,7 +307,11 @@
$commands = new MgFeatureCommandCollection();
$commands->Add(new MgInsertFeatures('BufferClass', $properties));
- $featureService->UpdateFeatures($bufferFeatureResId, $commands, false);
+ // Old way, pre MapGuide OS 2.0
+ //$featureService->UpdateFeatures($bufferFeatureResId, $commands, false);
+
+ // New way, post MapGuide OS 2.0
+ $bufferLayer->UpdateFeatures($commands);
// Ensure that the buffer layer is visible and in the legend.
@@ -252,7 +321,7 @@
$parcelMarkerLayer->SetVisible(true);
$parcelMarkerLayer->ForceRefresh();
- $map->Save($resourceService);
+ $map->Save();
}
}
Modified: branches/2.2/MgDev/Doc/samples/phpsamples/analyzing_features/task_pane.php
===================================================================
--- branches/2.2/MgDev/Doc/samples/phpsamples/analyzing_features/task_pane.php 2011-03-03 15:10:47 UTC (rev 5589)
+++ branches/2.2/MgDev/Doc/samples/phpsamples/analyzing_features/task_pane.php 2011-03-03 15:43:04 UTC (rev 5590)
@@ -54,7 +54,7 @@
?>
<ul>
<li>
- <a href="#" onClick="submitBufferRequest('/mapguide/phpsamples/analyzing_features/createbuffer.php'); return false;">
+ <a href="#" onClick="submitBufferRequest('../phpsamples/analyzing_features/createbuffer.php'); return false;">
Create buffer</a>
<br/>Create a buffer around a selected parcel.
<br/>
@@ -67,7 +67,7 @@
</li>
<li>
- <a href="#" onClick="submitBufferRequest('/mapguide/phpsamples/analyzing_features/selectfeaturesinbuffer.php'); return false;">
+ <a href="#" onClick="submitBufferRequest('../phpsamples/analyzing_features/selectfeaturesinbuffer.php'); return false;">
Find features in buffer</a>
<br/>Create a buffer around a selected parcel, then mark parcels inside the buffer that are
of type "MFG".
Modified: branches/2.2/MgDev/Doc/samples/phpsamples/common/common.php
===================================================================
--- branches/2.2/MgDev/Doc/samples/phpsamples/common/common.php 2011-03-03 15:10:47 UTC (rev 5589)
+++ branches/2.2/MgDev/Doc/samples/phpsamples/common/common.php 2011-03-03 15:43:04 UTC (rev 5590)
@@ -19,9 +19,9 @@
// -----------------------------------------------------------------------------------
// Use the following for Windows installations
// -----------------------------------------------------------------------------------
-$webExtensionsDirectory = 'C:\Program Files\MapGuideOpenSource\WebServerExtensions\\';
+$webExtensionsDirectory = 'C:\Program Files\OSGeo\MapGuide\Web\\';
-$MapGuideServerDirectory = 'C:\Program Files\MapGuideOpenSource\Server\\';
+$MapGuideServerDirectory = 'C:\Program Files\OSGeo\MapGuide\Server\\';
$viewerFilesDirectory = $webExtensionsDirectory . 'www\viewerfiles\\';
Modified: branches/2.2/MgDev/Doc/samples/phpsamples/digitizing_features/draw_line.php
===================================================================
--- branches/2.2/MgDev/Doc/samples/phpsamples/digitizing_features/draw_line.php 2011-03-03 15:10:47 UTC (rev 5589)
+++ branches/2.2/MgDev/Doc/samples/phpsamples/digitizing_features/draw_line.php 2011-03-03 15:43:04 UTC (rev 5590)
@@ -69,8 +69,8 @@
//---------------------------------------------------//
// Open the map
- $map = new MgMap();
- $map->Open($resourceService, $mapName);
+ $map = new MgMap($siteConnection);
+ $map->Open($mapName);
$layerName = "Lines";
$layerLegendLabel = "New Lines";
Modified: branches/2.2/MgDev/Doc/samples/phpsamples/main.php
===================================================================
--- branches/2.2/MgDev/Doc/samples/phpsamples/main.php 2011-03-03 15:10:47 UTC (rev 5589)
+++ branches/2.2/MgDev/Doc/samples/phpsamples/main.php 2011-03-03 15:43:04 UTC (rev 5590)
@@ -40,7 +40,7 @@
// Define some constants
$webLayout = "Library://Samples/Layouts/PHPSamples.WebLayout";
- $title = "PHP Samples";
+ $title = "MapGuide Developer's Guide PHP Samples";
}
catch (MgException $e)
{
@@ -62,9 +62,6 @@
<frameset rows="110,*" frameborder="NO" border="0" framespacing="0">
<frame src="common/Title.php?TitleText=<?= $title ?>" name="TitleFrame" scrolling="NO" noresize />
- <frame
- src="/mapguide/mapviewerajax/?
- SESSION=<?= $sessionId ?>&
- WEBLAYOUT=<?= $webLayout ?>" name="ViewerFrame" />
+ <frame src="/mapguide/mapviewerajax/?SESSION=<?= $sessionId ?>&WEBLAYOUT=<?= $webLayout ?>" name="ViewerFrame" />
</frameset>
</html>
Modified: branches/2.2/MgDev/Doc/samples/phpsamples/modifying_maps_and_layers/RecentlyBuilt.LayerDefinition
===================================================================
--- branches/2.2/MgDev/Doc/samples/phpsamples/modifying_maps_and_layers/RecentlyBuilt.LayerDefinition 2011-03-03 15:10:47 UTC (rev 5589)
+++ branches/2.2/MgDev/Doc/samples/phpsamples/modifying_maps_and_layers/RecentlyBuilt.LayerDefinition 2011-03-03 15:43:04 UTC (rev 5590)
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<LayerDefinition xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="LayerDefinition-1.1.0.xsd">
+<LayerDefinition xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="1.3.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="LayerDefinition-1.3.0.xsd">
<VectorLayerDefinition>
<ResourceId>Library://Samples/Sheboygan/Data/Parcels.FeatureSource</ResourceId>
<FeatureName>SHP_Schema:Parcels</FeatureName>
Modified: branches/2.2/MgDev/Doc/samples/phpsamples/modifying_maps_and_layers/create_new_point_layer_definition.php
===================================================================
--- branches/2.2/MgDev/Doc/samples/phpsamples/modifying_maps_and_layers/create_new_point_layer_definition.php 2011-03-03 15:10:47 UTC (rev 5589)
+++ branches/2.2/MgDev/Doc/samples/phpsamples/modifying_maps_and_layers/create_new_point_layer_definition.php 2011-03-03 15:43:04 UTC (rev 5590)
@@ -97,8 +97,10 @@
// Create the feature source
$featureSourceName = 'Library://Samples/DevGuide/Data/points.FeatureSource';
$resourceIdentifier = new MgResourceIdentifier($featureSourceName);
- $wkt = "LOCALCS[\"*XY-MT*\",LOCAL_DATUM[\"*X-Y*\",10000],UNIT[\"Meter\", 1],AXIS[\"X\",EAST],AXIS[\"Y\",NORTH]]";
- $sdfParams = new MgCreateSdfParams("ArbitraryXY", $wkt, $featureSchema);
+ //$wkt = "LOCALCS[\"*XY-MT*\",LOCAL_DATUM[\"*X-Y*\",10000],UNIT[\"Meter\", 1],AXIS[\"X\",EAST],AXIS[\"Y\",NORTH]]";
+ $wkt = 'GEOGCS["LL84",DATUM["WGS84",SPHEROID["WGS84",6378137.000,298.25722293]],PRIMEM["Greenwich",0],UNIT["Degree",0.01745329251994]]';
+ //$sdfParams = new MgCreateSdfParams("ArbitraryXY", $wkt, $featureSchema);
+ $sdfParams = new MgCreateSdfParams("LatLong", $wkt, $featureSchema);
$featureService->CreateFeatureSource($resourceIdentifier, $sdfParams);
// We need to add some data to the sdf before using it. The spatial context
Modified: branches/2.2/MgDev/Doc/samples/phpsamples/modifying_maps_and_layers/layer_functions.php
===================================================================
--- branches/2.2/MgDev/Doc/samples/phpsamples/modifying_maps_and_layers/layer_functions.php 2011-03-03 15:10:47 UTC (rev 5589)
+++ branches/2.2/MgDev/Doc/samples/phpsamples/modifying_maps_and_layers/layer_functions.php 2011-03-03 15:43:04 UTC (rev 5590)
@@ -20,26 +20,26 @@
// Adds the layer definition (XML) to the map.
// Returns the layer.
{
- global $schemaDirectory;
+ global $schemaDirectory;
// Validate the XML.
$domDocument = new DOMDocument;
$domDocument->loadXML($layerDefinition);
- if (! $domDocument->schemaValidate($schemaDirectory . "LayerDefinition-1.1.0.xsd") ) // $schemaDirectory is defined in common.php
- {
- echo "ERROR: The new XML document is invalid.<BR>\n.";
- return NULL;
- }
+ if (! $domDocument->schemaValidate($schemaDirectory . "LayerDefinition-1.3.0.xsd") ) // $schemaDirectory is defined in common.php
+ {
+ echo "ERROR: The new XML document is invalid.<BR>\n.";
+ return NULL;
+ }
- // Save the new layer definition to the session repository
- $byteSource = new MgByteSource($layerDefinition, strlen($layerDefinition));
- $byteSource->SetMimeType(MgMimeType::Xml);
- $resourceID = new MgResourceIdentifier("Session:$sessionId//$layerName.LayerDefinition");
- $resourceService->SetResource($resourceID, $byteSource->GetReader(), null);
-
- $newLayer = add_layer_resource_to_map($resourceID, $resourceService, $layerName, $layerLegendLabel, $map);
-
- return $newLayer;
+ // Save the new layer definition to the session repository
+ $byteSource = new MgByteSource($layerDefinition, strlen($layerDefinition));
+ $byteSource->SetMimeType(MgMimeType::Xml);
+ $resourceID = new MgResourceIdentifier("Session:$sessionId//$layerName.LayerDefinition");
+ $resourceService->SetResource($resourceID, $byteSource->GetReader(), null);
+
+ $newLayer = add_layer_resource_to_map($resourceID, $resourceService, $layerName, $layerLegendLabel, $map);
+
+ return $newLayer;
}
//////////////////////////////////////////////////////////////
@@ -47,24 +47,24 @@
// Adds a layer to a layer group. If necessary, it creates the layer group.
{
- // Get the layer group
- $layerGroupCollection = $map->GetLayerGroups();
- if ($layerGroupCollection->Contains($layerGroupName))
- {
- $layerGroup = $layerGroupCollection->GetItem($layerGroupName);
- }
- else
- {
- // It does not exist, so create it
- $layerGroup = new MgLayerGroup($layerGroupName);
- $layerGroup->SetVisible(true);
- $layerGroup->SetDisplayInLegend(true);
- $layerGroup->SetLegendLabel($layerGroupLegendLabel);
- $layerGroupCollection->Add($layerGroup);
- }
-
- // Add the layer to the group
- $layer->SetGroup($layerGroup);
+ // Get the layer group
+ $layerGroupCollection = $map->GetLayerGroups();
+ if ($layerGroupCollection->Contains($layerGroupName))
+ {
+ $layerGroup = $layerGroupCollection->GetItem($layerGroupName);
+ }
+ else
+ {
+ // It does not exist, so create it
+ $layerGroup = new MgLayerGroup($layerGroupName);
+ $layerGroup->SetVisible(true);
+ $layerGroup->SetDisplayInLegend(true);
+ $layerGroup->SetLegendLabel($layerGroupLegendLabel);
+ $layerGroupCollection->Add($layerGroup);
+ }
+
+ // Add the layer to the group
+ $layer->SetGroup($layerGroup);
}
//////////////////////////////////////////////////////////////
@@ -73,22 +73,22 @@
// repository) to the map.
// Returns the layer.
{
- $newLayer = new MgLayer($layerResourceID, $resourceService);
-
- // Add the new layer to the map's layer collection
- $newLayer->SetName($layerName);
- $newLayer->SetVisible(true);
- $newLayer->SetLegendLabel($layerLegendLabel);
- $newLayer->SetDisplayInLegend(true);
- $layerCollection = $map->GetLayers();
- if (! $layerCollection->Contains($layerName) )
- {
- // Insert the new layer at position 0 so it is at the top
- // of the drawing order
- $layerCollection->Insert(0, $newLayer);
- }
-
- return $newLayer;
+ $newLayer = new MgLayer($layerResourceID, $resourceService);
+
+ // Add the new layer to the map's layer collection
+ $newLayer->SetName($layerName);
+ $newLayer->SetVisible(true);
+ $newLayer->SetLegendLabel($layerLegendLabel);
+ $newLayer->SetDisplayInLegend(true);
+ $layerCollection = $map->GetLayers();
+ if (! $layerCollection->Contains($layerName) )
+ {
+ // Insert the new layer at position 0 so it is at the top
+ // of the drawing order
+ $layerCollection->Insert(0, $newLayer);
+ }
+
+ return $newLayer;
}
//////////////////////////////////////////////////////////////
Modified: branches/2.2/MgDev/Doc/samples/phpsamples/working_with_feature_data/task_pane.php
===================================================================
--- branches/2.2/MgDev/Doc/samples/phpsamples/working_with_feature_data/task_pane.php 2011-03-03 15:10:47 UTC (rev 5589)
+++ branches/2.2/MgDev/Doc/samples/phpsamples/working_with_feature_data/task_pane.php 2011-03-03 15:43:04 UTC (rev 5590)
@@ -32,7 +32,7 @@
params = new Array("SESSION", parent.parent.mapFrame.GetSessionId(),
"MAPNAME", parent.parent.mapFrame.GetMapName(),
"SELECTION", xmlSel);
- pageUrl = "/mapguide/phpsamples/working_with_feature_data/listselection.php";
+ pageUrl = "../phpsamples/working_with_feature_data/listselection.php";
parent.parent.formFrame.Submit(pageUrl, params, "taskPaneFrame");
}
</script>
More information about the mapguide-commits
mailing list