[mapguide-users] Bypassing initial view at startup
Nichols, Mark A.
markn at spicergroup.com
Fri Mar 23 00:44:17 EDT 2007
Interesting, we're working on the same problem. I have found an answer. I hope it helps you. Try these steps.
1. In MapGuide Studio, go to your web layout. There is an area "URL for home task displayed in the Task Pane". Change this to a new page. In my case, I changed this to a page called ../gt/initial.php.
2. Create your page initial.php.
3. Create a dummy page to set your variables in. In my case, I'm getting my x and y in a seperate PHP program. So I can set them as session variables and then retreive them in my initial.php page.
initial.php (the default page of the task pane)
-------------------------------
<?php
session_start();
$xLocation=$_SESSION["X"];;
$yLocation=$_SESSION["Y"];
$mapScale=$_SESSION["mapScale"];
if ($xLocation=="")
{
echo "No X,Y specified, continue with initial view.";
}
else
{
?>
<script language="javascript">
window.setTimeout("parent.parent.mapFrame.ZoomToView(<?php echo $xLocation; ?>, <?php echo $yLocation; ?>, <?php echo $mapScale; ?>, true)", 2000);
</script>
<?php
}
?>
setvar.php (some other page where I'm setting variables for the map to use)
-------------------------------
<?php
session_start();
session_register("X");
session_register("Y");
session_register("mapScale");
$_SESSION["X"]=656411;
$_SESSION["Y"]=321285;
$_SESSION["mapScale"]=15000;
?>
So the map opens, it starts to load with the initial zoom, but then the right frame quickly redirects it to the new coordinates. I had to have the window.setTimeout to give the page a little delay, otherwise the script wouldn't work.
It's not the best logic, but it works. Let me know if you have any problems with it.
Mark Nichols
________________________________
From: mapguide-users-bounces at lists.osgeo.org on behalf of FGoulet
Sent: Thu 3/22/2007 4:07 PM
To: mapguide-users at lists.osgeo.org
Subject: [mapguide-users] Bypassing initial view at startup
Hi,
When the MapGuide Viewer start, is there a way to zoom to an extent other
than what is it defined in the map layout initial view?
I know I can zoom after the map first apprears but I would really like to
bypass the initial view for a better user experience.
Thanks
--
View this message in context: http://www.nabble.com/Bypassing-initial-view-at-startup-tf3450031s16610.html#a9623015
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/ms-tnef
Size: 6223 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/mapguide-users/attachments/20070323/2a108a64/attachment.bin
More information about the mapguide-users
mailing list