[mapguide-users] re: fail to display marker in mgos 2.0.2

bongtk bongtk at sains.com.my
Mon Oct 27 19:55:02 EDT 2008


dear Zac Spitzer,

perhaps i should call it failing silently. but, it is not "time out". 
the whole codes are executed without errors. only thing is that the 
markers are not displayed.

the code is phpsample code shared for sheboygan application. the same 
problem happening even when i used the same sheboygan data and code, 
it works for MGOS 1.1, not 2.0.2. 

thanz for your prompt reply.

regards, bongtk
--------
<?php
    include 'appconstants.php';
    include 'utilityfunctions.php';
    include 'findparcelfunctions.php';

    $mgSessionId = ($_SERVER['REQUEST_METHOD'] == "POST")? $_POST
['SESSION']: $_GET['SESSION'];
    $matches = 0;   // Variable to control output results.
    $mapUpdated = false;

    try
    {

        MgInitializeWebTier ($configFilePath);

        $userInfo = new MgUserInformation($mgSessionId);
        $siteConnection = new MgSiteConnection();
        $siteConnection->Open($userInfo);

        // Initialize variables to be used in this script and create
        // instances of a FeatureService and ResourceService objects.

        $parcelMarkerFeatureSourceId = new MgResourceIdentifier
("Session:" . $mgSessionId  . "//ParcelMarker.FeatureSource");
        $parcelMarkerCommands = new MgFeatureCommandCollection();

        $resourceService = $siteConnection->CreateService
(MgServiceType::ResourceService);
        $featureService = $siteConnection->CreateService
(MgServiceType::FeatureService);

        // Determine if a previous Search has been run. If not create a
        // temporary ParcelMarker feature source and layer. Otherwise
        // just delete the previous search results.

        $map = new MgMap();
        $map->Open($resourceService, 'councilmap');

        $parcelMarkerLayer = GetLayerByName($map, 'ParcelMarker');
        if ($parcelMarkerLayer == null)
        {
            CreateParcelMarkerFeatureSource($featureService, 
$parcelMarkerFeatureSourceId);
            $parcelMarkerLayer = CreateParcelMarkerLayer
($resourceService, $parcelMarkerFeatureSourceId, $mgSessionId);

            $map->GetLayers()->Insert(0, $parcelMarkerLayer);
        }
        else
        {
            $parcelMarkerCommands->Add(new MgDeleteFeatures
('ParcelMarker', "ID like '%'"));
        }

        // If an owner was specified create a FeatureService object and
        // use it to query all of the parcels with an owner that 
matches
        $owner = trim($_GET['Owner']);
        if (strlen($owner) >= 0)
        {
            
            if (strlen($owner) > 0)
            {
             $filter = "NAME LIKE '%" . $owner . "%'";
            }
            else
            {
             $filter = "NAME LIKE '%%'";
            }
            $featureResId = new MgResourceIdentifier
("Library://council/building.FeatureSource");
            $queryOptions = new MgFeatureQueryOptions();
            $queryOptions->SetFilter($filter);

            $geometryReaderWriter = new MgAgfReaderWriter();

            $featureReader = $featureService->SelectFeatures
($featureResId, "building", $queryOptions);

            while ($featureReader->ReadNext())
            {
                $name = $featureReader->GetString('NAME');
                $byteReader = $featureReader->GetGeometry('GEOMETRY');

                $geometry = $geometryReaderWriter->Read($byteReader);
                $point = $geometry->GetCentroid();
                $x = $point->GetCoordinate()->GetX();
                $y = $point->GetCoordinate()->GetY();

                // Create an insert command for this parcel.

                $properties = new MgPropertyCollection();
                $properties->Add(new MgStringProperty('Owner', $name));
                $properties->Add(new MgGeometryProperty('Location', 
$geometryReaderWriter->Write($point)));
                $parcelMarkerCommands->Add(new MgInsertFeatures
('ParcelMarker', $properties));

                // Add a row to the hyperlink table for this parcel.

                echo '<tr><td class="NavItem">';
                echo "<br><a href=\"gotopointgooglebuilding.php?
X=$x&Y=$y&Scale=5000\" target=\"scriptFrame\"><font color =#dd0000 
size =4>  $name</font></a>";

                echo '<form action="findbuildingGE.php" method="get" 
target="scriptFrame">';
		echo '<input name="OWNER" type="hidden" value="' . 
$name . '">';        	echo '<input name="" type="submit" 
value="Google Earth">';
        	echo '</form>';

                echo '<form action="../council/mysql_display.php" 
method="get" target="New Window">';
		echo '<input name="OWNER" type="hidden" value="' . 
$name . '">';
        	echo '<input name="" type="submit" value="     
Rating     ">';
        	echo '</form></td></tr>';

                $matches++;
            }

            $featureReader->Close();

            echo '</table>';
            if ($parcelMarkerCommands->GetCount() > 0)
            {
                $featureService->UpdateFeatures
($parcelMarkerFeatureSourceId, $parcelMarkerCommands, false);

                $parcelMarkerLayer->SetVisible($matches > 0);
                $parcelMarkerLayer->ForceRefresh();

                $map->Save($resourceService);
                $mapUpdated = true;
            }
            else
            {
                echo '<tr><td class="NavItem">0 matches 
found.</td></tr>';
            }
        }
        else
        {
            echo '<tr><td class="NavItem">You must specify a Shopping 
Mall!</td></tr>';
        }
    }
    catch (MgException $e)
    {
        echo $filter;
        echo $e->GetMessage();
        echo $e->GetDetails();
    }
?>
----


is it throwing any errors or just failing silently? can you post any 
more code? On Wed, Oct 22, 2008 at 6:21 PM, bongtk 
<bongtk at sains.com.my> wrote:


>>>> dear all,
>>>>
>>>> goodday!
>>>> i had encountered problem of creating and displaying the marker 
>>    
>>
after

>>>> creating using the code below using mgos 2.0:
>>>>               $name = $featureReader->GetString('NAME');
>>>>               $byteReader = $featureReader->GetGeometry('GEOMETRY');
>>>>
>>>>               $geometry = $geometryReaderWriter->Read($byteReader);
>>>>               $point = $geometry->GetCentroid();
>>>>               $x = $point->GetCoordinate()->GetX();
>>>>               $y = $point->GetCoordinate()->GetY();
>>>>
>>>>               // Create an insert command for this parcel.
>>>>
>>>>               $properties = new MgPropertyCollection();
>>>>               $properties->Add(new MgStringProperty('Owner', 
>>    
>>
$name));

>>>>               $properties->Add(new MgGeometryProperty('Location',
>>>> $geometryReaderWriter->Write($point)));
>>>>               $parcelMarkerCommands->Add(new
>>>> MgInsertFeatures('ParcelMarker', $properties));
>>>>
>>>> i'd used the same code to display the marker using mgos 1.1 and it 
>>    
>>
works

>>>> well. can any of you give some advice?
>>>> appreciate, thanz a lot.
>>>>
>>>> regards, bongtk
>>    
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapguide-users/attachments/20081028/10f3ea4a/attachment.html


More information about the mapguide-users mailing list