[mapguide-users] Getting all object Enveloppe

Kenneth, GEOGRAF A/S ks at geograf.dk
Tue Jun 5 12:02:34 EDT 2007


You can modify the runtime map, just not the MapExtent, ViewCenter and 
ViewScale properties.

Regards, Kenneth, GEOGRAF A/S



David Hequet wrote:
> zspitzer>
> I'm using the Autodesk Mapguide Enterprise Server, si i can't use OS 1.2
> beta (i liked to..)
> And i have to use VB.net.. So no php..
>
> Kenneth>
> non-availability of modifying map or layout during the runtime. By Creating
> a layout i can't use the refresh method in the viewer? I have to reload the
> entire layout?
> Re-writing a "zoom to map extent" functionnality was my first idea, i used a
> command in the weblayout calling a custom ZoomExtent() javascript function.
> I used a zoomToView() command but i had no idea on how to calculate the
> scale with the dwf viewer (yeah, i have this constraint too..).
> I think now that i can calculate the scale by using GetDisplayHeight
> (),GetDisplayWidth () and 	GetDisplayDpi () MgMap's method (like the
> "zoomSelection()" ajaxviewer's method do)
>
> Harder is Better :p
>
>
> zspitzer wrote:
>   
>> the mapdefinition and weblayoutdefinition php classes are good for
>> this. look at the schemareport in 1.20 betas for examples on how use
>> them.
>>
>> note there are two versions of this library in the release. which aint
>> good, i am going to file a bug on that...one in schemareport, one in
>> mapviewerphp and they are slightly different.
>>
>> according to the docs they are only available in php
>>
>> z
>>
>> On 6/5/07, Kenneth, GEOGRAF A/S <ks at geograf.dk> wrote:
>>     
>>>  You are writing a map definition into the runtime map.
>>>  That will not work.
>>>
>>>  I don't know why, but you can't change the initial view in the runtime
>>> map,
>>> using the MapGuide API.
>>>  Perhaps someone else can explain why those properties are readonly?
>>>
>>>  Instead, you have to create a new MapDefinition (which is what you are
>>> doing).
>>>  The new MapDefinition must be saved, like you do, but with type
>>> MgResourceType.MapDefinition.
>>>
>>>  Then you must create/copy a WebLayout, modify the MapDefinition of the
>>> layout, and save the layout.
>>>  Now you can start the browser, and point to the new WebLayout to display
>>> your map.
>>>
>>>
>>>
>>>  I think you will have an easier time modifying the ajaxmappane.templ
>>> file.
>>>  It has a function called InitialMapView() which shows how the extent is
>>> calculated.
>>>  You might provide your own extension here that updates the orgExt
>>> variables.
>>>
>>>  If you wan't it to work with an unmodified server, you have to update
>>> these
>>> variables some other way.
>>>  If you wan't it to work with the DWF viewer, you have to use the
>>> approach
>>> outlined above.
>>>
>>>
>>>  Regards. Kenneth, GEOGRAF A/S
>>>
>>>
>>>  David Hequet wrote:
>>>  Thank you, i wrote a method using my method (using au selection object).
>>> I
>>> will try to optimize it with your advice later. I'm curently busy with
>>> the
>>> "set the extent to the map in the session" part of my dev. Here is what i
>>> did:
>>>
>>> 'infos:
>>> 'me._map = map resource in the session
>>> 'aMgEnveloppe = valid mgenveloppe of my data
>>> 'me._sessionId = current mapguide session
>>>
>>> Dim aMgByteReader As MgByteReader
>>> Dim aContent As String
>>> Dim anXmlDoc As XmlDocument
>>> Dim anXmlNode As XmlNode
>>> Dim aRootNode As XmlNode
>>>
>>> ' lecture du contenu de definition de la carte pour retrouver le nom de
>>> la
>>> resource associée
>>> aMgByteReader =
>>> Me._resourceService.GetResourceContent(Me._map.GetMapDefinition())
>>> aContent = aMgByteReader.ToString()
>>> anXmlDoc = New XmlDocument()
>>> anXmlDoc.LoadXml(aContent)
>>>
>>> aRootNode = anXmlDoc.DocumentElement
>>> ' modification des etendues
>>> anXmlNode = aRootNode.SelectSingleNode("Extents/MinX")
>>> anXmlNode.ChildNodes(0).Value =
>>> aMgEnveloppe.GetLowerLeftCoordinate.GetX
>>> anXmlNode = aRootNode.SelectSingleNode("Extents/MinY")
>>> anXmlNode.ChildNodes(0).Value =
>>> aMgEnveloppe.GetLowerLeftCoordinate.GetY
>>> anXmlNode = aRootNode.SelectSingleNode("Extents/MaxX")
>>> anXmlNode.ChildNodes(0).Value =
>>> aMgEnveloppe.GetUpperRightCoordinate.GetX
>>> anXmlNode = aRootNode.SelectSingleNode("Extents/MaxY")
>>> anXmlNode.ChildNodes(0).Value =
>>> aMgEnveloppe.GetUpperRightCoordinate.GetY
>>>
>>> Dim anXmlStream As MemoryStream = New MemoryStream()
>>>
>>> anXmlDoc.Save(anXmlStream)
>>> Dim aMapDefinition() As Byte = anXmlStream.ToArray()
>>> Dim utf8 As Encoding = Encoding.UTF8
>>> Dim aMapDefStr As String = New String(utf8.GetChars(aMapDefinition))
>>> aMapDefinition = New Byte(aMapDefStr.Length - 1) {}
>>> 'Dim byteCount As Integer = utf8.GetBytes(aMapDefStr, 1,
>>> aMapDefStr.Length -
>>> 1, aMapDefinition, 0)
>>>
>>> Dim aByteSource As MgByteSource = New MgByteSource(aMapDefinition,
>>> aMapDefinition.Length())
>>> aByteSource.SetMimeType(MgMimeType.Xml)
>>>
>>> Dim aMgByteReader2 As MgByteReader = aByteSource.GetReader()
>>>
>>> Dim mapStateId As MgResourceIdentifier = New
>>> MgResourceIdentifier("Session:"
>>> + Me._sessionId + "//" + Me._map.GetName() + "." + MgResourceType.Map)
>>> Me._resourceService.SetResource(mapStateId, aMgByteReader,
>>> Nothing)
>>>
>>> I don't have any error, but when i refresh the map or try a "zoom to
>>> initial
>>> view" nothing happen.
>>> Maybe might i update the weblayout's initial view? (but scale calc
>>> needed..)
>>>
>>> Anyone got an idea?
>>> Thank you
>>>
>>>
>>> Kenneth, GEOGRAF A/S wrote:
>>>
>>>
>>>  You don't have to use the selection part.
>>> You can extract the object directly from the feature reader.
>>> Once you have the object, you can also get the extent (aka bbox).
>>> If you then construct an envelope object, you can add the features
>>> envelope to original envelope.
>>>
>>> Something like:
>>>
>>> create a new MgFeatureQueryOptions with an empty filter
>>> create a new Envelope
>>> For Each Layer
>>> {
>>>  Use a featureReader with the MgFeatureQueryOptions
>>>  Add the feature's envelope to the outer Envelope
>>> }
>>> Get zoom extents from the Envelope
>>>
>>>
>>> Other than this, I don't think you can optimize it anymore, as you need
>>> to execute the query on each layer.
>>>
>>> I think there is a "Get Extents" on the feature source, but I can't find
>>> it. And I don't think it works on filtered datasources.
>>>
>>> Perhaps you can execute the query with some SQL optimizations like
>>> "Select Envelope(geometry) from datasource".
>>>
>>> Hope it helps.
>>>
>>> Regards, Kenneth, GEOGRAF A/S
>>>
>>>
>>>
>>> David Hequet wrote:
>>>
>>>
>>>  Hello,
>>>
>>> I'm trying to make a fonction that can return me the enveloppe of the
>>> entire
>>> visible map (no way with original map extent).
>>>
>>> Explain: I have a map "template" with a lot of layers, i have a function
>>> that change all the layer filter (basic filter, no spatial) to see
>>> different
>>> map based on that template. Doing that make the "zoom to original extent"
>>> useless, because data are not on the same area.
>>> I wan't to set the new map extent in the MapDefinition.
>>> My ask is about getting the new extent.
>>>
>>> I thought to do it like that:
>>>
>>> create a new MgSelection
>>> create a new MgFeatureQueryOptions with an empty filter
>>> For Each Layer
>>> {
>>>  Use a featureReader with the MgFeatureQueryOptions
>>>  Add the selected feature to the MgSelection
>>> }
>>> Getting the MgSelection enveloppe
>>>
>>> It will work, but i don't think it's very optimized with a lot of
>>> Layer/Feature (and it will used at each map load, filter modification..)
>>>
>>> Did someone have a better way?
>>>
>>> Thank you!
>>>
>>> Ps: sorry for my poor english, ask i you want precision.
>>>
>>>
>>>  _______________________________________________
>>> 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
>>>
>>>
>>>       
>> -- 
>> Zac Spitzer
>> http://zacster.blogspot.com/
>> +61 3 9018 5778 (voip via my pc)
>> +61 405 847 168
>> _______________________________________________
>> mapguide-users mailing list
>> mapguide-users at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/mapguide-users
>>
>>
>>     
>
>   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapguide-users/attachments/20070605/9803f3aa/attachment.html


More information about the mapguide-users mailing list