To Implement ZoomToSelection in Fusion Viewer MapGuide Enterprise 2011
发布日期:2021-09-03 20:14:05 浏览次数:2 分类:技术文章

本文共 1920 字,大约阅读时间需要 6 分钟。

As we discussed in previous blog about , we can zoom to specified view port by calling ZoomToView. But it would be great if there is an API by which we can zoom to the current selection. OK, let’s do it ourselves.

 

To make it part of our public Fuion viewer API, we can edit the MapGuideViewerApi.js file, which locates at C:\Program Files\Autodesk\MapGuideEnterprise2011\WebServerExtensions\www\fusion\layers\MapGuide by default. Here is the JavaScript code, you can copy and paste it into MapGuideViewerApi.js

function ZoomToSelection(){    var mapWidget = Fusion.getWidgetById(mgApiMapWidgetId);    if (mapWidget && mapWidget.hasSelection()) {        mapWidget.getSelection(_zoomtoselection_handler)    }    else    {        alert('No selection, please select some features first.');    }}//private function function _zoomtoselection_handler(multiSelection){    var mapWidget = Fusion.getWidgetById(mgApiMapWidgetId);    var selection = multiSelection[mapWidget.getMapName()];    var lowerLeftCoord = selection.getLowerLeftCoord();    var upperRightCoord= selection.getUpperRightCoord();     var centerX = upperRightCoord.x - (upperRightCoord.x - lowerLeftCoord.x)/2;    var centerY = upperRightCoord.y - (upperRightCoord.y - lowerLeftCoord.y)/2;    var scale = mapWidget.getScale();    ZoomToView(centerX,centerY,scale,true);    }

If you don’t want to muss up the source code of the product, you can only add it to your project (your page), just a little modification needed. code as below:

 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="FusionViewerAPIDemo.aspx.cs"    Inherits="FusionViewerAPIDemo" %>        <%--reference the fusion viewer API javascript file--%>            

 

Happy MapGuiding!

峻祁连

作者:
邮箱:junqilian@163.com 
出处:  
转载请保留此信息。
本文转自峻祁连. Moving to Cloud/Mobile博客园博客,原文链接:http://www.cnblogs.com/junqilian/archive/2010/06/04/1751679.html
,如需转载请自行联系原作者

转载地址:https://blog.csdn.net/weixin_34194702/article/details/90119211 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:AE92 SDK for Java 窗体简例
下一篇:一个简单粗暴的前后端分离方案

发表评论

最新留言

做的很好,不错不错
[***.243.131.199]2024年04月17日 07时26分35秒