[mapguide-users] How to show a map (PHP)
David Hequet
david.hequet at free.fr
Tue Jun 26 06:18:02 EDT 2007
i'm not sure it's possible to use
$resourceService->SetResource($resourceId, $byteSource->GetReader(), null);
for a mapdefinition.
I now undestand what you wan't to do:
To modify or create a mapdefinition before the layout loading
Here is what you can find in the Audoesk devnotes: (it was in C#, i used it
in VB.NET and it works)
This emulate what Mapguide do when you access a Layout:
If you want to get the MgMap object programmatically without displaying a
map in the Viewer (either DWF or AJAX), you need to follow these steps.
1. Initialize web tier with an ini file.
2. Connect to the site.
3. Instantiate an MgMap object.
4. Call MgMap.Create to actually create it.
5. Save the MgMap object to your session with MgMap.Save.
//1. $sessionId = valid session id
//2. $ressourceService = valid ressourceService
//3.
$aMap = new MgMap();
//4.
$resId = new
MgResourceIdentifier("Library://Samples/Map/".$aMapName.".MapDefinition");
$aMap->Create($resourceService, $resId, $aMapName);
//5.
$mapStateId = new
MgResourceIdentifier("Session:{$sessionId}//{$aMapName}.Map");
$aMap->Save($resourceService,$mapStateId);
hope this can help you, in VB.NET i had no problem, but in php i had an
"acces denied" error
if it work send me a mail please!
mates wrote:
>
> I think i found a way..
> Is it possible to save a MgMap object by useing
>
> $resourceService->SetResource($resourceId, $byteSource->GetReader(),
> null); ??
>
> How i get $byteSource from MgMap object?
>
>
>
>
> mates wrote:
>>
>> Hi
>>
>> I now the devguide and how it's work (Weblayout -> MapDefinition ->
>> LayerDefinition -> FeatureSource) but i want an application that let the
>> user first select few layers from a list (LayerDefinition are in Library
>> defined) and then create a map with selected layers and show it.
>> I try to save it to a MapDefinition back
>>
>> $mapDefId = new MgResourceIdentifier("Library://22/mapa.MapDefinition");
>> $map->Save($resourceService, $mapDefId)
>>
>> but it doesn't work :( I have this MapDefinition predefined in Weblayout.
>> I only need to save the created MgMap to a existing MapDefinition in
>> Library..
>>
>> Thank you for helping me :)
>>
>>
>>
>>
>>
>> David Hequet wrote:
>>>
>>> Look at the Tutorial provided with Mapguide Studio to create an entire
>>> map from Data to Weblayout.
>>> The look at the "Hello Map" sample in devguide (you can download it
>>> here) that is a working php sample wich show a Map
>>> Ps: You can't show a map in a browser, you can only show a weblayout.
>>> The Tutorial's is a good point to undestand how work mapguide (before
>>> going trough the code)
>>>
>>>
>>> mates wrote:
>>>>
>>>> Hi
>>>> Sorry, but I don't understood well what you mean. Can u pls explain
>>>> better, Im a beginner :) I have already created a Weblayout, but I
>>>> don't know how to get this map to this Weblayout. Show me a exapmle
>>>> pls..
>>>> Thank you..
>>>>
>>>>
>>>>
>>>> Mansoureh Sadrykia wrote:
>>>>>
>>>>> Hi!
>>>>>
>>>>> Why don't you use mapguide studio to create a webLayout and then
>>>>> define its address in your library by PHP?(As the code you've written
>>>>> for the mapDefinition)
>>>>>
>>>>> mates <reklamama at centrum.sk> wrote:
>>>>>
>>>>> I create a map and then i add a layer. Now i need it to show the map
>>>>> in the
>>>>> browser, but i don't know how to do it using PHP :(
>>>>> Can you help me pls?
>>>>>
>>>>>
>>>>> include "constants.php";
>>>>> MgInitializeWebTier('webconfig.ini');
>>>>>
>>>>> $site = new MgSite();
>>>>> $userInfo = new MgUserInformation("Administrator", "admin");
>>>>>
>>>>> $site->Open($userInfo);
>>>>>
>>>>> $id = $site->CreateSession();
>>>>>
>>>>> $siteConnection = new MgSiteConnection();
>>>>> $siteConnection->Open($userInfo);
>>>>> $resourceService =
>>>>> $siteConnection->CreateService(MgServiceType::ResourceService);
>>>>>
>>>>> $mapDefId = new
>>>>> MgResourceIdentifier("Library://22/mapa.MapDefinition");
>>>>> $map = new MgMap();
>>>>> $mapName = $mapDefId->GetName();
>>>>> $map->Create($resourceService, $mapDefId, $mapName);
>>>>>
>>>>> $LayID = new
>>>>> MgResourceIdentifier("Library://22/kraje.LayerDefinition");
>>>>>
>>>>> $newLayer = new MgLayer($LayID, $resourceService);
>>>>>
>>>>> $newLayer->SetVisible(true);
>>>>> $newLayer->SetLegendLabel($newLayer->GetName());
>>>>> $newLayer->SetDisplayInLegend(true);
>>>>>
>>>>> $layerCollection->Insert(0, $newLayer);
>>>>>
>>>>> $mapId = new MgResourceIdentifier("Session:$id//$name." .
>>>>> MgResourceType::Map);
>>>>> $map->Save($resourceService, $mapId);
>>>>>
>>>>> And what now? :)
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/How-to-show-a-map-%28PHP%29-tf3973550s16610.html#a11279107
>>>>> Sent from the MapGuide Users mailing list archive at Nabble.com.
>>>>>
>>>>> _______________________________________________
>>>>> mapguide-users mailing list
>>>>> mapguide-users at lists.osgeo.org
>>>>> http://lists.osgeo.org/mailman/listinfo/mapguide-users
>>>>>
>>>>>
>>>>>
>>>>> ---------------------------------
>>>>> Need a vacation? Get great deals to amazing places on Yahoo! Travel.
>>>>> _______________________________________________
>>>>> mapguide-users mailing list
>>>>> mapguide-users at lists.osgeo.org
>>>>> http://lists.osgeo.org/mailman/listinfo/mapguide-users
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>
--
View this message in context: http://www.nabble.com/How-to-show-a-map-%28PHP%29-tf3973550s16610.html#a11303100
Sent from the MapGuide Users mailing list archive at Nabble.com.
More information about the mapguide-users
mailing list