[mapguide-users] ZoomToView in Javascript
Carrillo, John
JBCarrillo at rcflood.org
Wed Feb 2 12:51:36 EST 2011
Hello All,
I'm new to Mapguide. I am trying to get the ZoomToView to
run but am having issues. I can get it to work if I place my .aspx page
in the Task Pane of the map. But when I try to use it from an .aspx page
from outside of the task pane it doesn't work. The map loads fine and my
query works fine, I get results but I can't seem to get any javascript
to run on the map. I hard coded the coordinates for the ZoomToView in
the code below. The same code works fine when run from the Task Pane but
again I'd like to run it from outside the Task Pane. Thanks
<%
'from the previous page
Dim sessionId As [String] = Request.Form.[Get]("SESSION")
Dim encroachPermit As [String] = Request.Form.[Get]("iAPN")
Dim webLayout As [String] = "Library://JC_Test/WebLayer/C.WebLayout"
'path to web config
Dim realPath As String =
Request.ServerVariables("APPL_PHYSICAL_PATH")
Dim configPath As [String] = realPath & "webconfig.ini"
MapGuideApi.MgInitializeWebTier("C:\Program
Files\AutoDesk\MapGuideEnterprise2011\WebServerExtensions\www\webconfig.
ini")
Dim userInfo As New MgUserInformation(sessionId)
Dim siteConnection As New MgSiteConnection()
siteConnection.Open(userInfo)
Dim resService As MgResourceService =
DirectCast(siteConnection.CreateService(MgServiceType.ResourceService),
MgResourceService)
Dim featureService As MgFeatureService =
DirectCast(siteConnection.CreateService(MgServiceType.FeatureService),
MgFeatureService)
'Map from Map Guide
Dim map As New MgMap()
map.Open(resService, "C")
'Query for the second condition
Dim nameQuery As New MgFeatureQueryOptions()
nameQuery.SetFilter("APN = '" & encroachPermit & "'")
'second feature sources to compare first to
Dim encroachId As New MgResourceIdentifier("Library://Oracle Feature
Source/FCT1TEST_Assessor feature source.FeatureSource")
Dim featureReader As MgFeatureReader =
featureService.SelectFeatures(encroachId, "PARCELPTS", nameQuery)
Dim list As New ArrayList()
Dim x_coordinate As New ArrayList()
Dim y_coordinate As New ArrayList()
While featureReader.ReadNext()
list.Add(featureReader.GetString("APN"))
End While
'Highlight the query result on the map
Dim selection As New MgSelection(map)
Dim layer As MgLayer = map.GetLayers().GetItem("C_Parcels")
featureReader = featureService.SelectFeatures(encroachId,
"PARCELPTS", nameQuery)
selection.AddFeatures(layer, featureReader, 0)
Dim selectionXML As [String] = selection.ToXml()
Dim selectionXML2 As [String] = selection.ToXml()
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Make Query</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
/>
<meta http-equiv="content-script-type" content="text/javascript" />
<meta http-equiv="content-style-type" content="text/css" />
<script type="text/javascript">
function onPageLoad() {
parent.parent.ZoomToView(6249630.51, 2281462.61, 5000,
true);
}
</script>
</head>
<body id="body1" class="AppFrame" onload="onPageLoad()">
<strong>The following are the query results: </strong>
<ul>
<%
For i As Integer = 0 To list.Count - 1
Dim address As [String] = list(i).ToString()
If address <> "" Then
Response.Write("<li>" & list(i).ToString() & "</li>"
& vbLf)
End If
Next
%>
</ul>
<iframe id="imap"
src="/mapguide2011/mapviewernet/ajaxviewer.aspx?SESSION=<%=
sessionId %>&WEBLAYOUT=<%= webLayout %>" name="ViewerFrame" height="700"
width="1200" scrolling="yes" />
</body>
</html>
Thanks,
JC
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapguide-users/attachments/20110202/99737eaa/attachment.html
More information about the mapguide-users
mailing list