Infrastructure Map Server General Discussion

Infrastructure Map Server General Discussion

Reply
Valued Contributor
pg002a
Posts: 58
Registered: ‎08-03-2010
Message 1 of 8 (1,081 Views)
Accepted Solution

Zoomtoview in Fusion

1081 Views, 7 Replies
04-09-2013 12:49 AM

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?

 

 

 

Valued Mentor
jackie.ng
Posts: 277
Registered: ‎10-06-2008
Message 2 of 8 (1,066 Views)

Re: Zoomtoview in Fusion

04-09-2013 08:10 PM in reply to: pg002a

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

 

- Jackie

Valued Contributor
pg002a
Posts: 58
Registered: ‎08-03-2010
Message 3 of 8 (1,055 Views)

Re: Zoomtoview in Fusion

04-10-2013 03:53 AM 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.

 

Valued Mentor
gluckett
Posts: 374
Registered: ‎10-10-2003
Message 4 of 8 (972 Views)

Re: Zoomtoview in Fusion

05-17-2013 12:30 PM 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);
    }
}

Valued Contributor
pg002a
Posts: 58
Registered: ‎08-03-2010
Message 5 of 8 (953 Views)

Re: Zoomtoview in Fusion

05-21-2013 04:34 AM 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.

Valued Mentor
gluckett
Posts: 374
Registered: ‎10-10-2003
Message 6 of 8 (948 Views)

Re: Zoomtoview in Fusion

05-21-2013 05:07 AM 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);
    }

Valued Contributor
pg002a
Posts: 58
Registered: ‎08-03-2010
Message 7 of 8 (932 Views)

Re: Zoomtoview in Fusion

05-21-2013 11:00 PM in reply to: gluckett

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

Valued Mentor
gluckett
Posts: 374
Registered: ‎10-10-2003
Message 8 of 8 (925 Views)

Re: Zoomtoview in Fusion

05-22-2013 05:39 AM 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);
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.