[mapguide-users] Add Point to Existing Layer
Jackie Ng
jackie.ng at aecsystems.com.au
Sun Feb 3 17:25:21 EST 2008
Open two browser windows/tabs, one to your web application that adds the
points. Another to the schemareport page (usually at
http://servername:port/mapguide/schemareport/main.php )
Run your add point routine, then check if the schemareport for that feature
source has included the point you have just added.
If the point is there, then i suspect it is something to do with the layer
that's based off of the feature source.
Otherwise, your php script is clearly failing to insert the new point
feature.
- Jackie
gaku wrote:
>
> Yes,I have created site resources by use Administrator username.
>
>
>
> -gaku
>
>
> Jackie Ng wrote:
>>
>> Oh I see, I thought you were adding points to a session-based feature
>> source.
>>
>> In that case, did you create a mapguide session via a username that has
>> permissions to modify site resources?
>>
>> - Jackie
>>
>>
>> gaku wrote:
>>>
>>> Yes, I have created the feature source by using Mapguide Studio.
>>>
>>>
>>> Jackie Ng wrote:
>>>>
>>>> Have you actually created the feature source pointed to by
>>>> $featureSourceId ? (ie. Have you called
>>>> $featureService->CreateFeatureSource() ?)
>>>>
>>>> - Jackie
>>>>
>>>>
>>>> gaku wrote:
>>>>>
>>>>> Hi all
>>>>>
>>>>> I'm trying to let the user insert a point feature in PHP along with
>>>>> some attributes. The feature source is an SDF file and the code was
>>>>> translated/modified from the PHP example (draw_line). The user can get
>>>>> the X, Y coordinates from another button (works fine).
>>>>>
>>>>> Everything compiles fine and execute well but no feature is added to
>>>>> the feature source. I tried with a converted SDF feature source (didnt
>>>>> change a thing).
>>>>>
>>>>> Did I miss something ? Did I do something wrong :)
>>>>>
>>>>> Any help would be appreciated
>>>>>
>>>>> here's the code :
>>>>>
>>>>> ------------------------------------------------------------
>>>>>
>>>>> try
>>>>> {
>>>>> MgInitializeWebTier($webconfigFilePath);
>>>>>
>>>>> // Get the session information passed from the viewer.
>>>>> $sessionId = ($_SERVER['REQUEST_METHOD'] ==
>>>>> "POST")?$_POST['SESSION']: $_GET['SESSION'];
>>>>>
>>>>> // Get the user information using the session id,
>>>>> // and set up a connection to the site server.
>>>>> $userInfo = new MgUserInformation($sessionId);
>>>>> $siteConnection = new MgSiteConnection();
>>>>> $siteConnection->Open($userInfo);
>>>>>
>>>>>
>>>>> $resourceService =
>>>>> $siteConnection->CreateService(MgServiceType::ResourceService);
>>>>> $featureService =
>>>>> $siteConnection->CreateService(MgServiceType::FeatureService);
>>>>> $featureSourceId = new
>>>>> MgResourceIdentifier('Library://Sample/Data/020101Markup.FeatureSource');
>>>>>
>>>>>
>>>>> $map = new MgMap();
>>>>> $map->Open($resourceService, $mgMapName);
>>>>>
>>>>> //$geometryFactory = new MgGeometryFactory();
>>>>> $wktReaderWriter = new MgWktReaderWriter();
>>>>> $agfReaderWriter = new MgAgfReaderWriter();
>>>>>
>>>>> $geo = $wktReaderWrite->Read("POINT XY ( $x, $y )");
>>>>>
>>>>> $geoByteReader = new MgByteReader();
>>>>> $geoByteReader = $agfReaderWriter->Write($geo);
>>>>>
>>>>> $idid = 500;
>>>>>
>>>>> $propertyValues = new MgPropertyCollection();
>>>>> $propertyValues->Add(new MgInt32Property("ID", $idid ));
>>>>> $propertyValues->Add(new MgStringProperty(name, 'test'));
>>>>> $propertyValues->Add(new MgGeometryProperty('Geometry',
>>>>> $geoByteReader));
>>>>>
>>>>> $commands = new MgFeatureCommandCollection();
>>>>> $commands->Add(new MgInsertFeatures('020101Markup',
>>>>> $propertyValues));
>>>>> $featureService->UpdateFeatures($featureSourceId, $commands, false);
>>>>>
>>>>>
>>>>> }
>>>>> catch (MgException $e)
>>>>> {
>>>>> $errorMsg = $e->GetMessage();
>>>>> $errorDetail = $e->GetDetails();
>>>>> }
>>>>>
>>>>>
>>>>> -------------------------------end of code -------------
>>>>>
>>>>> --Thanks,
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>
--
View this message in context: http://www.nabble.com/Add-Point-to-Existing-Layer-tp15136337s16610p15259312.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
More information about the mapguide-users
mailing list