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: 

Zoomtoview in Fusion

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
pg002a
57935 Views, 9 Replies

Zoomtoview in Fusion

HI

 

Want to use  ZoomToView(x, y, scale, refresh)  function in Fusion like its works in Ajax viewer calling this function by creating  Invoke Script.  Just cant this function working in Fusion.  Does someone have working script for it?

 

 

 

9 REPLIES 9
Message 2 of 10
jackie.ng
in reply to: pg002a

fusion\layers\MapGuide\MapGuideViewerApi.js has a shim ZoomToView() function

 

- Jackie

Message 3 of 10
pg002a
in reply to: jackie.ng

 I created Invoke Script and entered code below:

 

function ZoomToView(60000, 650000, 20000, refresh) {
    //var Fusion = window.top.Fusion;
    var mapWidget = Fusion.getWidgetById(mgApiMapWidgetId);
    if (mapWidget && mapWidget.isMapLoaded()) {
        var extent = mapWidget.getExtentFromPoint(x, y, scale);
        mapWidget.setExtents(extent);
    }
}

Want to call this function in current mapframe so when I klick Invoke Script button then map are zoomed to desired location. I specified Target frame as "mapFrame".

Still problem get this working, I think I'm missing something.

 

Message 4 of 10
gluckett
in reply to: pg002a

Try:

 

function ZoomToView(60000, 650000, 20000, refresh) {
    var Fusion = window.top.mapFrame.Fusion;
    var mapWidget = Fusion.getWidgetById('Map');
    if (mapWidget && mapWidget.isMapLoaded()) {
        var extent = mapWidget.getExtentFromPoint(x, y, scale);
        mapWidget.setExtents(extent);
    }
}

Message 5 of 10
pg002a
in reply to: gluckett

I tried this code. Just copied this code to Studio invoke script window and specified target as mapFrame but still not working.

I add screenshot how its look like in Studo. I'm using open source Mapguide 2.5.

Message 6 of 10
gluckett
in reply to: pg002a

oh, if you are putting it in the INVOKESCRIPT, you don't need the "function"

 

just put this in your invokescript:

 

 

    var mapWidget = Fusion.getWidgetById('Map');
    if (mapWidget && mapWidget.isMapLoaded()) {
        var extent = mapWidget.getExtentFromPoint(60000, 650000, 20000);
        mapWidget.setExtents(extent);
    }

Message 7 of 10
pg002a
in reply to: gluckett

Code works but now i have new problem, pan function is not working after ZoomToview function.

Message 8 of 10
gluckett
in reply to: pg002a

If you want the PAN to be automatically selected after you zoom put this in the bottom of your INVOKESCRIPT:

 

 var panWidget=Fusion.getWidgetsByType('Pan')[0]; 
    panWidget.uiObj.setActive(true);
Message 9 of 10
nik.mazreen
in reply to: gluckett

Hi,

 

Is it possible to add marker for this zoomtoview function? if can be done, may i know how to do that.

i have code below and it successfully zoom to the coordinate that i entered. but how do i show marker for the coordinate that i entered?

<html xmlns="http://www.w3.org/1999/xhtml">
<title></title>
<script type="text/javascript" language="javascript" src="../../layers/MapGuide/MapGuideViewerApi.js"></script>
<script type="text/javascript" src="proj4js-1.1.0/lib/proj4js-compressed.js"></script>
<script type="text/javascript">

//Proj4js.defs["EPSG:4326"]="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"
var source = new Proj4js.Proj('EPSG:4326');
Proj4js.defs["EPSG:3857"]="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs"
var dest = new Proj4js.Proj('EPSG:3857');

function ZoomToView() {
//var Fusion = window.top.Fusion;
var latlong = document.getElementById('longlat').value;


var p = new Proj4js.Point(latlong)
Proj4js.transform(source, dest, p);
var scale = 2500.0003;//20000//15000//10000//5000//2000//1500
var mapWidget = GetFusionMapWidget();
if (mapWidget && mapWidget.isMapLoaded()) {
var extent = mapWidget.getExtentFromPoint(p.x, p.y, scale);
mapWidget.setExtents(extent);
}
}
</script>
<style>
h1{
font-size:20px;
font-family: "Calibri";
}

h2{
font-size:15px;
font-family: "Calibri";
}
</style>

<body>
<div>
<h1> Search Coordinate</h1> <p>
<h2> Enter The Coordinate</h2> <p>
<input type="text" id="longlat" placeholder="In decimal degrees, eg. 102.xxxx, 6.xxxx"><br><br>

<button type="button" onclick="ZoomToView()">Search</button>
</div>
</body>
</html>

 

thx in advance

 

-nik-

 

Message 10 of 10
gluckett
in reply to: nik.mazreen

If the Add the following to your INDEX.HTML for whatever Flexible Web Layout your are using:

 

<script type="text/javascript" src="../../../layers/MapGuide/MapGuideViewerApi.js"></script>

 

You can then use the DigitizePoint to put a point there.

 

For example:  

DigitizePoint(OnPointDigitized);


 

 

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

Post to forums  

Autodesk Design & Make Report