<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
You are writing a map definition into the runtime map. <br>
That will not work.<br>
<br>
I don't know why, but you can't change the initial view in the runtime
map, using the MapGuide API.<br>
Perhaps someone else can explain why those properties are readonly?<br>
<br>
Instead, you have to create a new MapDefinition (which is what you are
doing).<br>
The new MapDefinition must be saved, like you do, but with type
MgResourceType.MapDefinition.<br>
<br>
Then you must create/copy a WebLayout, modify the MapDefinition of the
layout, and save the layout.<br>
Now you can start the browser, and point to the new WebLayout to
display your map.<br>
<br>
<br>
<br>
I think you will have an easier time modifying the ajaxmappane.templ
file.<br>
It has a function called InitialMapView() which shows how the extent is
calculated. <br>
You might provide your own extension here that updates the orgExt
variables.<br>
<br>
If you wan't it to work with an unmodified server, you have to update
these variables some other way.<br>
If you wan't it to work with the DWF viewer, you have to use the
approach outlined above.<br>
<br>
<pre class="moz-signature" cols="72">Regards. Kenneth, GEOGRAF A/S
</pre>
<br>
David Hequet wrote:
<blockquote cite="mid10968414.post@talk.nabble.com" type="cite">
  <pre wrap="">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:
  </pre>
  <blockquote type="cite">
    <pre wrap="">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:
    </pre>
    <blockquote type="cite">
      <pre wrap="">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.
  
      </pre>
    </blockquote>
    <pre wrap="">_______________________________________________
mapguide-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:mapguide-users@lists.osgeo.org">mapguide-users@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/mapguide-users">http://lists.osgeo.org/mailman/listinfo/mapguide-users</a>


    </pre>
  </blockquote>
  <pre wrap=""><!---->
  </pre>
</blockquote>
</body>
</html>