[mapguide-users] SV: Runtime map problem

Maksim Sestic max at geoinova.com
Wed Dec 3 06:10:45 EST 2008


You shoudn't do that. Instead, create a resource package and either upload
it to MG server via admin console or using Meastro API. Once resource
package is part of the library repository - you can change resource
properties (i.e. map, layer visibility, feature source, applied queries,
etc) and display resulting data/graphics via client app.

-----Original Message-----
From: mapguide-users-bounces at lists.osgeo.org
[mailto:mapguide-users-bounces at lists.osgeo.org] On Behalf Of padmini
godavarthi
Sent: Wednesday, December 03, 2008 12:01
To: mapguide-users at lists.osgeo.org
Subject: Re: [mapguide-users] SV: Runtime map problem



Hi,
Thanks .its working fine now.

To build a map, you must have all the components:
1. FeatureSource, references data
2. LayerDefinition, references a FeatureSource 3. MapDefinition, references
multiple LayerDefinitions 4. WebLayout, references a MapDefinition

All these items must be in a repository (either Library or Session) 

I know the procedure to create it in mapguide maestro.


   1) Now my problem was  i want to create   ALL the above items
programmetically (my input is only a shape file)  byusing maestro dll.


If u know this plz help me

Regards,
Padmini.



Kenneth Skovhede, GEOGRAF A/S wrote:
> 
> I wrote a follow up, with corrected code.
> You are using the initial one, and you are missing a "?" mark in the 
> redirect URL.
> 
> Try to use the updated version, and beware of the question mark in the 
> Response.Redirect call.
> 
> 
> Regards, Kenneth Skovhede, GEOGRAF A/S
> 
> 
> 
> padmini godavarthi skrev:
>> Hi,
>> Thanks for u r reply.
>>
>>
>> I tried this code but i got an error that
>>
>> Server Error in '/maestro' Application.
>> ---------------------------------------------------------------------
>> -----------
>>
>> HTTP Error 400 - Bad Request. 
>>
>> ---------------------------------------------------------------------
>> ----------- Version Information: ASP.NET Development Server 8.0.0.0
>>
>>
>> my code was
>>
>>     Dim host As New
>> Uri("http://localhost/mapguide/mapagent/mapagent.fcgi")
>>         Dim conn As New HttpServerConnection(host, "Administrator", 
>> "admin", "en", True)
>>
>>         'You have to change the string below to point at a valid 
>> WebLayout
>>
>>         Dim weblayout As WebLayout =
>> conn.GetWebLayout("Library://Filebased
>> data/Layout/layout.WebLayout")
>>         Dim mapdefinition As MapDefinition =
>> conn.GetMapDefinition(weblayout.Map.ResourceId)
>>         weblayout.Map.InitialView = New MapViewType()
>>         weblayout.Map.InitialView.Scale = 2000 'Zoom to 1:2000
>>         weblayout.Map.InitialView.CenterX = 
>> (mapdefinition.Extents.MaxX -
>> mapdefinition.Extents.MinX) + mapdefinition.Extents.MinX
>>         weblayout.Map.InitialView.CenterY = 
>> (mapdefinition.Extents.MaxY -
>> mapdefinition.Extents.MinX) + mapdefinition.Extents.MinY
>>
>>         Dim tempid As ResourceIdentifier = New 
>> ResourceIdentifier("layout", 
>> OSGeo.MapGuide.MaestroAPI.ResourceTypes.WebLayout, conn.SessionID)
>>
>>         Response.Redirect("/mapguide/ajaxviewer/WEBLAYOUT=" &
>> Server.UrlEncode(tempid)
>>
>> joscsu wrote:
>>   
>>>  Or this:
>>> System.Guid.NewGuid().ToString()
>>>
>>>
>>> ----- Ursprungligt meddelande ----
>>> Från: Maksim Sestic <max at geoinova.com>
>>> Till: MapGuide Users Mail List <mapguide-users at lists.osgeo.org>
>>> Skickat: tisdag 2 december 2008 16:49:21
>>> Ämne: RE: [mapguide-users] Runtime map problem
>>>
>>> Try this:
>>>
>>> System.Guid.NewGuid()
>>>
>>>
>>>
>>> -----Original Message-----
>>> From: mapguide-users-bounces at lists.osgeo.org
>>> [mailto:mapguide-users-bounces at lists.osgeo.org] On Behalf Of padmini 
>>> godavarthi
>>> Sent: Tuesday, December 02, 2008 15:35
>>> To: mapguide-users at lists.osgeo.org
>>> Subject: Re: [mapguide-users] Runtime map problem
>>>
>>>
>>> Hi,
>>> Thanku very much for ur help
>>> i tried this code
>>> but i got an error in the line
>>>
>>> Dim tempid as ResourceIdentifier = new 
>>> ResourceIdentifier(Guid.NewGuid(),
>>> OSGeo.MapGuide.MaestroAPI.ResourceTypes.WebLayout, con.SessionID)
>>>
>>> because of this Guid.NewGuid()
>>>
>>> 1) Actually what is this?
>>> 2) Which paramater we have to pass in this place instead of
>>> Guid.NewGuid()
>>>
>>>
>>> Regards,
>>> Padmini
>>>
>>>
>>>
>>>
>>> Kenneth Skovhede, GEOGRAF A/S wrote:
>>>     
>>>> I forgot to save the weblayout in the code below :(
>>>>
>>>> Updated version is:
>>>>
>>>> 'Setup connection
>>>> Dim host As New
>>>> Uri("http://localhost/mapguide/mapagent/mapagent.fcgi")
>>>> Dim conn As New HttpServerConnection(host, "Administrator", 
>>>> "admin", "en", True)
>>>>
>>>> 'You have to change the string below to point at a valid WebLayout 
>>>> Dim weblayout as WebLayout =
>>>> con.GetWebLayout("Library://mylayout.WebLayout")
>>>> Dim mapdefinition as MapDefinition =
>>>> con.GetMapDefinition(weblayout.Map.ResourceId)
>>>>
>>>> 'Modify the initial view of the weblayout weblayout.Map.InitialView 
>>>> = new MapViewType() weblayout.Map.InitialView.Scale = 2000 'Zoom to 
>>>> 1:2000 weblayout.Map.InitialView.CenterX = 
>>>> (mapdefinition.Extents.MaxX
>>>> -
>>>> mapdefinition.Extents.MinX) + mapdefinition.Extents.MinX 
>>>> weblayout.Map.InitialView.CenterY = (mapdefinition.Extents.MaxY -
>>>> mapdefinition.Extents.MinX) + mapdefinition.Extents.MinY
>>>>
>>>> 'Obtain a unique session based id for the temporary weblayout 
>>>> (which is a copy of an existing WebLayout) Dim tempid as 
>>>> ResourceIdentifier = new ResourceIdentifier(Guid.NewGuid(),
>>>> OSGeo.MapGuide.MaestroAPI.ResourceTypes.WebLayout, con.SessionID)
>>>>
>>>> 'Save the layout, otherwise you can't reference it 
>>>> con.SaveResourceAs(weblayout, tempid)
>>>>
>>>> 'Open the viewer, and use the temporary layout, since the map only 
>>>> exists in the 'current session, we must use that session, and NOT 
>>>> supply username/password
>>>> 'BEWARE: The session belongs to the Administrator account, so the 
>>>> user gets full access to MapGuide (delete, modify, etc.) 
>>>> Response.Redirect("/mapguide/ajaxviewer/?WEBLAYOUT=" &
>>>> Server.UrlEncode(tempid) & "&SESSION=" &
>>>> Server.UrlEncode(con.SessionID))
>>>>
>>>>
>>>> Regards, Kenneth Skovhede, GEOGRAF A/S
>>>>
>>>>
>>>>
>>>> Kenneth Skovhede, GEOGRAF A/S skrev:
>>>>       
>>>>> To build a map, you must have all the components:
>>>>> 1. FeatureSource, references data
>>>>> 2. LayerDefinition, references a FeatureSource 3. MapDefinition, 
>>>>> references multiple LayerDefinitions 4. WebLayout, references a 
>>>>> MapDefinition
>>>>>
>>>>> All these items must be in a repository (either Library or 
>>>>> Session), otherwise they can't be referenced.
>>>>>
>>>>> When you write that you want to "create a WebLayout 
>>>>> programatically", do you want to create ALL the above items, or do 
>>>>> you have layers and featuresources?
>>>>>
>>>>> (1) If you want to generate a WebLayout ResourceID, you should use:
>>>>> Dim res As New ResourceIdentifier("Filebased data/Maps/mapdata",
>>>>> ResourceTypes.WebLayout)
>>>>> If you want to read the name of an existing MapDefinition from 
>>>>> another layout, you must do:
>>>>> Dim weblayout as WebLayout =
>>>>> con.GetWebLayout("Library://mylayout.WebLayout")
>>>>> Dim res as String = webLayout.Map.ResourceId
>>>>>
>>>>> (2) I don't understand the question.
>>>>>
>>>>> (3) The MapDefinition is an Xml document. Inside, it references 
>>>>> layers, which references featuresources, as described above. It is 
>>>>> very slow to do this, so when you open a map in the browser, the 
>>>>> xml is transformed into a binary object. This object contains all 
>>>>> the info from the MapDefinition and some info from the layers and 
>>>>> featuresources.
>>>>>
>>>>> You need to know this, because if you try to toggle layer 
>>>>> visibility in the MapDefinition, nothing happens. In short, the 
>>>>> Runtime Map is a binary object that you can manipulate using the 
>>>>> MapGuide (and Maestro)-API, and it only works for a displayed map.
>>>>> Upon startup, the Runtime Map is identical to the MapDefinition it 
>>>>> was created from.
>>>>>
>>>>>
>>>>> A short example of using an existing WebLayout:
>>>>>
>>>>> Dim host As New
>>>>> Uri("http://localhost/mapguide/mapagent/mapagent.fcgi")
>>>>> Dim conn As New HttpServerConnection(host, "Administrator", 
>>>>> "admin", "en", True)
>>>>>
>>>>> 'You have to change the string below to point at a valid WebLayout
>>>>>   
>>>>> Dim weblayout as WebLayout =
>>>>> con.GetWebLayout("Library://mylayout.WebLayout")
>>>>> Dim mapdefinition as MapDefinition =
>>>>> con.GetMapDefinition(weblayout.Map.ResourceId)
>>>>> weblayout.Map.InitialView = new MapViewType() 
>>>>> weblayout.Map.InitialView.Scale = 2000 'Zoom to 1:2000 
>>>>> weblayout.Map.InitialView.CenterX = (mapdefinition.Extents.MaxX -
>>>>> mapdefinition.Extents.MinX) + mapdefinition.Extents.MinX 
>>>>> weblayout.Map.InitialView.CenterY = (mapdefinition.Extents.MaxY -
>>>>> mapdefinition.Extents.MinX) + mapdefinition.Extents.MinY Dim 
>>>>> tempid as ResourceIdentifier = new 
>>>>> ResourceIdentifier(Guid.NewGuid(),
>>>>> OSGeo.MapGuide.MaestroAPI.ResourceTypes.WebLayout, con.SessionID) 
>>>>> Response.Redirect("/mapguide/ajaxviewer/?WEBLAYOUT=" &
>>>>> Server.UrlEncode(tempid) & "&USERNAME=Anonymous&PASSWORD=")
>>>>>
>>>>>
>>>>> Regards, Kenneth Skovhede, GEOGRAF A/S
>>>>>   
>>>>>
>>>>> padmini godavarthi skrev:
>>>>>         
>>>>>> Hi,
>>>>>> Thanks for u r reply
>>>>>>
>>>>>> actually i wrote the code as
>>>>>>
>>>>>>
>>>>>>     Dim host As New
>>>>>> Uri("http://localhost/mapguide/mapagent/mapagent.fcgi")
>>>>>>         Dim conn As New HttpServerConnection(host, 
>>>>>> "Administrator", "admin", "en", True)
>>>>>>         Dim res As New ResourceIdentifier("Filebased 
>>>>>> data/Maps/mapdata",
>>>>>> ResourceTypes.MapDefinition)
>>>>>>         Dim mapId As String = res.ResourceId
>>>>>>
>>>>>>
>>>>>> with that i got the map resource id.
>>>>>>
>>>>>> But actually to run the application the url in the browser must 
>>>>>> be like
>>>>>>
>>>>>>
>>>>>> http://localhost/mapguide/mapviewerajax/?WEBLAYOUT=Library%3a%2f%
>>>>>> 2fF
>>>>>> ilebased+data%2fLayout%2flayout.WebLayout
>>>>>>
>>>>>> 1) How can i get this weblayout (like
>>>>>> Library%3a%2f%2fFilebased+data%2fLayout%2flayout.WebLayout)
>>>>>> programmetically
>>>>>>
>>>>>> 2) I want to redirect to the ajax viewer sample application 
>>>>>> through asp.net (like given by u )
>>>>>>       
>>>>>> Response.Redirect("/mapguide/ajaxviewer/?WEBLAYOUT=...resourceId
>>>>>> for
>>>>>> your WebLayout...&USERNAME=Anonymous&PASSWORD=");
>>>>>>
>>>>>> 3) Can u plz tell me the purpose of runtime map (actualli iam in 
>>>>>> configusing
>>>>>> state)
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> Kenneth Skovhede, GEOGRAF A/S wrote:
>>>>>>   
>>>>>>           
>>>>>>> Instead of re-posting the original question, could you try to 
>>>>>>> explain what parts of my previous reply that are unclear or wrong?
>>>>>>>
>>>>>>> http://www.nabble.com/How-to-Load-Runtime-map-in-mapviewerajax-t
>>>>>>> o20
>>>>>>> 704038.html#a20769349
>>>>>>>
>>>>>>> Regards, Kenneth Skovhede, GEOGRAF A/S
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> padmini godavarthi skrev:
>>>>>>>     
>>>>>>>             
>>>>>>>>   Hi ,
>>>>>>>> iam using mapguide open source 2.0( with .Net 2.0 + IIS 5.1) 
>>>>>>>> Iam using dotnet viewer sample while running the application i 
>>>>>>>> observed that the layout path given in the application.
>>>>>>>>
>>>>>>>> as
>>>>>>>>
>>>>>>>> String webLayout =
>>>>>>>> "Library://Samples/Sheboygan/Layouts/SheboyganAspTiled.WebLayou
>>>>>>>> t";
>>>>>>>>
>>>>>>>>   it works but now i want to create this weblayout in run time 
>>>>>>>> (by
>>>>>>>> code)
>>>>>>>> using mapguide maestro api
>>>>>>>>
>>>>>>>> for this purpose i followed the link
>>>>>>>>
>>>>>>>> http://trac.osgeo.org/mapguide/wiki/maestro/MaestroAPI/samples/
>>>>>>>> Run
>>>>>>>> timeMap
>>>>>>>>
>>>>>>>> but i didnt get any out.
>>>>>>>>
>>>>>>>> can u plz tell me
>>>>>>>>
>>>>>>>> 1) how to create this weblayout in run time
>>>>>>>> 2) How it will works
>>>>>>>>
>>>>>>>> If u know this plz tell me the procedure.
>>>>>>>>
>>>>>>>>
>>>>>>>> Regards,
>>>>>>>> Padmini.
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>   
>>>>>>>>       
>>>>>>>>               
>>>>>>> _______________________________________________
>>>>>>> mapguide-users mailing list
>>>>>>> mapguide-users at lists.osgeo.org
>>>>>>> http://lists.osgeo.org/mailman/listinfo/mapguide-users
>>>>>>>
>>>>>>>
>>>>>>>     
>>>>>>>             
>>>>>>   
>>>>>>           
>>>>> ------------------------------------------------------------------
>>>>> ---
>>>>> ---
>>>>>
>>>>> _______________________________________________
>>>>> mapguide-users mailing list
>>>>> mapguide-users at lists.osgeo.org
>>>>> http://lists.osgeo.org/mailman/listinfo/mapguide-users
>>>>>   
>>>>>         
>>>> _______________________________________________
>>>> 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/Runtime-map-problem-tp20789983p20793385.html
>>> 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
>>>
>>> __________ Information from ESET NOD32 Antivirus, version of virus 
>>> signature database 3658 (20081202) __________
>>>
>>> The message was checked by ESET NOD32 Antivirus.
>>>
>>> http://www.eset.com
>>>
>>>
>>>
>>> _______________________________________________
>>> mapguide-users mailing list
>>> mapguide-users at lists.osgeo.org
>>> http://lists.osgeo.org/mailman/listinfo/mapguide-users
>>>
>>>
>>>
>>>       __________________________________________________________
>>> Låna pengar utan säkerhet. Jämför vilkor online hos Kelkoo.
>>> http://www.kelkoo.se/c-100390123-lan-utan-sakerhet.html?partnerId=96
>>> 915014 _______________________________________________
>>> mapguide-users mailing list
>>> mapguide-users at lists.osgeo.org
>>> http://lists.osgeo.org/mailman/listinfo/mapguide-users
>>>
>>>
>>>     
>>
>>   
> 
> _______________________________________________
> 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/Runtime-map-problem-tp20789983p20810836.html
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

__________ Information from ESET NOD32 Antivirus, version of virus signature
database 3660 (20081203) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com





More information about the mapguide-users mailing list