Changes between Initial Version and Version 1 of maestro/MaestroAPI/samples/RuntimeMap


Ignore:
Timestamp:
08/26/08 01:27:56 (16 years ago)
Author:
MaksimS
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • maestro/MaestroAPI/samples/RuntimeMap

    v1 v1  
     1= Utilizing RuntimeMap via Meastro API =
     2
     3Just a quick one on creating and using RuntimeMaps via Meastro API. To get Meastro API going please download latest Meastro package, then reference OSGeo.MapGuide.MaestroAPI.dll and MapGuideDotNetApi.dll only. This example uses Maestro API HttpServerConnection object which talks to the MG's mapagent.fcgi via HTTP. In other words - you example (ASP.NET page) may reside on remote computer calling MG server via HTTP.
     4
     5(VB.NET)
     6{{{
     7Imports OSGeo.MapGuide.MaestroAPI
     8...
     9
     10' Create an Uri object pointing to mapagent.fcgi location
     11Dim host As New Uri("http://myserver/mapguide2009/mapagent/mapagent.fcgi")
     12
     13' Create HttpServerConnection object with credentials enabling establishing a session
     14Dim conn As New HttpServerConnection(host, "Administrator", "admin", "en", True)
     15
     16' Get a helper reference object to a Map resource named PLAN stored in a Library
     17Dim res As New ResourceIdentifier("MyFolder/Maps/PLAN", ResourceTypes.MapDefinition)
     18
     19' Let ResourceIdentifier helper class tell us map's ResourceId
     20Dim mapId As String = res.ResourceId
     21
     22' Now get MapDefinition for our map named PLAN
     23Dim mapDef As MapDefinition = conn.GetMapDefinition(mapId)
     24
     25' Here, ResourceIdentifier helper class tells us map name
     26Dim mapName As String = res.Name
     27
     28' Now we decide on a name for our runtime map (stored in a Session)
     29Dim rtMapId As String = "Session:" + conn.SessionID + "//" + mapName + ".Map"
     30
     31' Finally, we're telling HttpServerConnection to create runtime map
     32conn.CreateRuntimeMap(rtMapId, mapDef)
     33
     34' And here it is - an instance of our brand new RuntimeMap object
     35Dim rtMap As RuntimeClasses.RuntimeMap = conn.GetRuntimeMap(rtMapId)
     36}}}
     37
     38Having a reference to RuntimeMap enables us manipulating Library-resident map "clone" (see conn.CreateRuntimeMap) sitting in a Session. Don't forget - each MG Session may have different instance of RuntimeMap in it. When RuntimeMap is created, it's properties (including layers, layer visibility, etc.) is inherited from the original MapDefinition. Let's change visibility of PARCELS layer initially turned off:
     39
     40{{{
     41' Simply tell the PARCELS layer to turn on
     42rtMap.Layers("PARCELS").Visible = True
     43
     44' Don't forget - you need to commit any change to RuntimeMap using HttpServerConnection.SaveRuntimeMap() method
     45conn.SaveRuntimeMap(rtMapId, rtMap)
     46}}}
     47
     48That's it for starters. More to come.
     49
     50