[mapguide-users] Layer Zooming
padmini godavarthi
godavarthi.padmini at gmail.com
Tue May 5 08:03:12 EDT 2009
Hi Kenneth,
Thank u very much foor ur quick response.
i have seen ur code in php
in this code after gettikg maxx,maxy,minx,miny waht i have to
do????????????///
i think i dont have necessity to create mapdefinition,web layout all these
thinkgs right???????????
my code is as
follows...............................................................
Dim serverVars As NameValueCollection = Request.ServerVariables
Dim strServerVars As String = ""
Dim str1 As String
For Each str1 In serverVars.AllKeys
strServerVars += "<br>" & str1
Next
Dim platform As String = serverVars("SERVER_SOFTWARE")
Dim queryStr As String = serverVars("QUERY_STRING")
Dim queryStr1 As String = serverVars("Form")
Dim requestParams As NameValueCollection = IIf(Request.HttpMethod =
"POST", Request.Form, Request.QueryString)
Dim sessionId As String = Request.QueryString("SESSION")
Dim realPath As String =
Request.ServerVariables("APPL_PHYSICAL_PATH")
Dim configPath As String = realPath + "webconfig.ini"
MapGuideApi.MgInitializeWebTier(configPath)
Dim userInfo As MgUserInformation = New MgUserInformation(sessionId)
Dim siteConnection As MgSiteConnection = New MgSiteConnection
siteConnection.Open(userInfo)
Dim resService As MgResourceService =
siteConnection.CreateService(MgServiceType.ResourceService)
Dim featureService As MgFeatureService =
siteConnection.CreateService(MgServiceType.FeatureService)
Dim shortclass As New MgClassDefinition()
Dim map As MgMap = New MgMap()
map.Open(resService, "mapdata")
Dim value As String = ""
Dim filterText As String = ""
Dim areaRuleXML As String = ""
Dim areaDoc As XmlDocument = Nothing
Dim areaNode As XmlNode = Nothing
Dim portion As Double = 0.0
Dim layers As MgLayerCollection = map.GetLayers()
Dim layer As MgLayer = CType(layers.GetItem("IMC_ROAD_LINK"),
MgLayer)
Dim resId As MgResourceIdentifier = New
MgResourceIdentifier(layer.GetFeatureSourceId())
Dim layerDefResId As MgResourceIdentifier =
layer.GetLayerDefinition()
Dim byteReader As MgByteReader =
resService.GetResourceContent(layerDefResId)
Dim doc As New XmlDocument()
Dim xmlLayerDef As String = byteReader.ToString()
doc.LoadXml(xmlLayerDef)
Dim nodeList As XmlNodeList =
doc.GetElementsByTagName("VectorScaleRange")
Dim vectorScaleRangecElement As XmlElement = CType(nodeList.Item(0),
XmlElement)
Dim areaTypeStyle As XmlElement =
CType(vectorScaleRangecElement.GetElementsByTagName("LineTypeStyle").Item(0),
XmlElement)
Dim areaRuleList As XmlNodeList =
areaTypeStyle.GetElementsByTagName("LineRule")
Dim count As Integer = areaRuleList.Count
For iq As Integer = 0 To count - 1
areaTypeStyle.RemoveChild(areaRuleList.Item(0))
Next
Dim areaRuleTemplate As String =
File.ReadAllText(GetThemeXmlTemplatePath())
Dim queryoptions As MgFeatureQueryOptions = New
MgFeatureQueryOptions()
queryoptions.AddFeatureProperty("LINK_ID")
'queryoptions.SetFilter("LINK_ID IN (147)")
Dim query3 As String
' queryoptions.SetFilter("LINK_ID=147 or LINK_ID=148 or LINK_ID=149
or LINK_ID=150")
Dim arr() As String = Strings.Split(strq(0), ",")
Dim aw As Integer = arr.Length
For a As Integer = 0 To aw - 1
If a = 0 Then
query3 = "LINK_ID=" & arr(0)
Else
query3 = query3 & " or LINK_ID=" & arr(a)
End If
Next
queryoptions.SetFilter(query3)
Dim increment1 As Double = IIf((5 > 1), 1.0 / (5 - 1), 1.0)
Dim str As String = layer.GetFeatureClassName()
Dim dataReader1 As MgFeatureReader =
featureService.SelectFeatures(resId, layer.GetFeatureClassName(),
queryoptions)
While dataReader1.ReadNext()
value = GetFeaturePropertyValue(dataReader1, "LINK_ID")
filterText = """ + "LINK_ID" + "" = "
filterText = filterText + value
areaRuleXML = String.Format(areaRuleTemplate, "LINK_ID" + ":" +
value, filterText, InterpolateColor(portion, "00FF00", "00FF00", 0),
InterpolateColor(portion, "00FF00", "00FF00", 0))
areaDoc = New XmlDocument()
areaDoc.LoadXml(areaRuleXML)
areaNode = doc.ImportNode(areaDoc.DocumentElement, True)
areaTypeStyle.AppendChild(areaNode)
portion = portion + increment1
End While
dataReader1.Close()
Dim xmlString As String = doc.DocumentElement.OuterXml
Dim layerResId As MgResourceIdentifier = New
MgResourceIdentifier("Session:" + sessionId + "//" + "short path" +
".LayerDefinition")
resService.SetResource(layerResId, New MgByteReader(xmlString,
"text/xml"), Nothing)
Dim newLayer As MgLayer = New MgLayer(layerResId, resService)
Dim legendLabel As String = "Shortest Path"
newLayer.SetName("Shortest Path")
newLayer.SetLegendLabel(legendLabel)
newLayer.SetDisplayInLegend(layer.GetDisplayInLegend())
newLayer.SetVisible(True)
newLayer.SetSelectable(layer.GetSelectable())
layers.Insert(layers.IndexOf(layer), newLayer)
map.Save(resService)
End Sub
In this case what i have to doo??????????///
plzzz tell me the solution..............................
Regards,
Padmini.
Kenneth Skovhede, GEOGRAF A/S wrote:
>
> You need to get the extent of the layer, and then zoom to it.
>
> There are two extents in FDO, the spatial extents, and the combined
> object extents.
> For some providers, this is the same value, for others only one of the
> extents work.
> In other words, you have to handle both situations.
> Fortunately, there is a PHP implementation that does just that, and you
> can see the code here:
> http://trac.osgeo.org/mapguide/browser/trunk/MgDev/Web/src/schemareport/showgeom.php
>
> Look at line 95 to 161 to see how its done.
> You have to port this to .Net yourself.
>
> After you get the extent, you can zoom to the extent.
> Another solution is to select all the features in the temp layer (if
> they are selectable),
> and the execute zoomToSelection.
>
> Regards, Kenneth Skovhede, GEOGRAF A/S
>
>
>
> padmini godavarthi skrev:
>> Hi Kenneth,
>> Thanks for ur reply
>> i achieved to do shortest path through oracle procedure and added to this
>> result as a seperate layer on the map.
>>
>> But Now i want the functionality of Zoom to layer (i mean to this
>> shortest
>> path layer)
>>
>> How is it possible????????????????????????
>>
>> Plz tell me the solution.....
>>
>> Regards,
>> Padmini................
>>
>>
> _______________________________________________
> mapguide-users mailing list
> mapguide-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapguide-users
>
>
--
View this message in context: http://n2.nabble.com/Layer-Zooming-tp2792234p2792534.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
More information about the mapguide-users
mailing list