Infrastructure Map Server Forum
Welcome to Autodesk’s Infrastructure Map Server Forums. Share your knowledge, ask questions, and explore popular Infrastructure Map Server topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MapGuide zoomtoview

1 REPLY 1
Reply
Message 1 of 2
bulatova99
639 Views, 1 Reply

MapGuide zoomtoview

Hi,

I created a Weblayout in Mapguide. I would like zoom to coordinates, when I open my map in browser with x and y coordinates and scale parameters. (Here is my link: http://localhost:8008/mapguide/mymap/index.php?x=640221&y=560647&scale=1000)
How can I use 'zoomtoview' function in this index.php.

Here is my index.php

 

<?php
$installDir =
'C:\\Program Files\\OSGeo\\MapGuide\\';
$extensionsDir = $installDir . 'Web\\www\\';
$viewerDir = $installDir . 'mapviewerphp\\';

include $viewerDir . 'constants.php';
include $viewerDir . 'common.php';

MgInitializeWebTier($extensionsDir . 'webconfig.ini');

$site = new MgSite();
$site->Open(new MgUserInformation("Anonymous", ""));

$sessionId = $site->CreateSession();
$webLayout = "Library://mylayout/layouts/webindex.WebLayout";

$x = $_REQUEST["x"];
$y = $_REQUEST["y"];
$scale = $_REQUEST["scale"];
//echo "($x.$y.$scale)"
?>

<html>
<head>
<title>mylayout</title>
</head>
<body marginheight="0" marginwidth="0">
<iframe id="viewerFrame" width="100%" height="100%" frameborder=0
scrolling="no"
src="/mapguide/mapviewerajax/?SESSION=<?= $sessionId ?>&
WEBLAYOUT=<?= $webLayout ?>"></iframe>
</html>

 

I'm a beginner in PHP and javascript.

Can anyone suggest solutions?
Thanks,

1 REPLY 1
Message 2 of 2
gluckett
in reply to: bulatova99

You can do it a number of ways.  I like the idea of loading the map first and then once it is loaded, change the zoom.

 

I would do something like what is seen at: http://trac.osgeo.org/mapguide/wiki/CodeSamples/JavaScript/AJAXViewerEventHooking

 

except in the OnMapInitialized() you can use the followining in your PHP page.

 

// Map loaded handlerfunction OnMapInitialized() {
    // Map has been initialized now we're off to the races.     
var x =<?= $_REQUEST["x"]; ?>;
var y =<?= $_REQUEST["y"]; ?>;
var scale = <?= $_REQUEST["scale"]; ?>;
viewerFrame. ZoomToView(x,y,scale,true);
}

I would look at too: https://osgeo.org/webdav/mapguide/docs/viewerapi/viewerapi.html  for the JAVASCRIPT API

 

Also, your x and y might need parseFloat(x) and parseFloat(y) to make sure they are Floats.

 

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report