EPR类企业管理系统

在我们现有系统基础上或全新开发,提供定制服务
为您的企业高效快速实施ERP,WMS,MES,CRM管理系统
全面管控物料仓库、销售业务、采购业务、仓库业务
生产过程、质量检验、组织架构、业务报表


定制
QQ:460-3528

开发
QQ群:3360-90194

源码
微信:136-3650-3721

如何:使用人类可读的位置而不是数字坐标来指定地图中心

本主题描述如何在根据“使用栅格地图”教程创建的应用程序中使用JavaScript代码直接访问dxMap小部件。如果您需要自定义未映射到“模型编辑器”中IModelMapSettings或IModelMobileMapSettings节点的属性的窗口小部件选项,则可能需要执行此操作。在此示例中,使用人类可读地址(而非数字坐标)自定义指定在小部件中心显示的位置的中心选项。在其autoAdjust选项也发生了变化。

  • 面向ASP.NET的控制器

    using DevExpress.Persistent.Base;
    using DevExpress.ExpressApp.Maps.Web;
    // ...
    public class WebMapCenterController : ViewController {
        public WebMapCenterController() {
            TargetObjectType = typeof(IMapsMarker);
            TargetViewType = ViewType.ListView;
        }
        protected override void OnViewControlsCreated() {
            base.OnViewControlsCreated();
            WebMapsListEditor mapsListEditor = ((ListView)View).Editor as WebMapsListEditor;
            if (mapsListEditor != null) {
                mapsListEditor.MapViewer.ClientSideEvents.Customize = @"
    function(sender, map) {
        map.option('center', 'Brooklyn Bridge, New York, NY');
        map.option('autoAdjust', false);
    }";
            }
        }
    }
    

    结果显示在下图中。

    Maps_BrooklynBridge

  • 面向移动的控制器

    • MobileMapCenterController视图控制器添加到Mobile模块项目中。
    • 在构造函数中,例如,将ViewController.TargetViewId属性设置为MapsMarker_ListView
    • 重写OnViewControlsCreated方法,并访问MobileMapsListEditor列表编辑器及其Map控件。
    • 用字符串指定控件的Map.OnCustomize属性,该字符串是JavaScript客户端事件,用于更改centerautoAdjust选项。请注意,JavaScript代码应放在方括号中。
    using DevExpress.ExpressApp;
    using DevExpress.ExpressApp.Maps.Mobile;
    using DevExpress.ExpressApp.Maps.Mobile.Editors;
    //...
    public class MobileMapCenterController : ViewController<ListView> {
        public MobileMapCenterController() {
            TargetViewId = "MapsMarker_ListView";
        }
        protected override void OnViewControlsCreated() {
            base.OnViewControlsCreated();
            MobileMapsListEditor mobileMapsListEditor = View.Editor as MobileMapsListEditor;
            if (mobileMapsListEditor != null) {
                Map map = mobileMapsListEditor.Control as Map;
                map.OnCustomize = @"
                (function(map) {
                    map.option('center', 'Brooklyn Bridge,New York,NY');
                    map.option('autoAdjust', 'false');
                })";
            }
        }
    }
    

    结果显示在下图中。

    Maps_BrooklynBridge_Mobile

相关文章

转载保留此链接,注明出处