首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >extJs门户内的extJs gmappanel

extJs门户内的extJs gmappanel
EN

Stack Overflow用户
提问于 2012-05-07 20:28:40
回答 3查看 2.5K关注 0票数 6

我想把extJS Gmappanel放在extJs门户中。下面是示例extJS门户。在“谷歌”portlet,我需要有谷歌地图。

如何在extJs门户中创建extJs gmappanel?

代码语言:javascript
复制
Ext.define('Ext.app.Portal', {
    extend: 'Ext.container.Viewport',
    uses: ['Ext.app.PortalPanel', 'Ext.app.PortalColumn', 'Ext.app.GridPortlet', 'Ext.app.ChartPortlet'],
    getTools: function() {
        return [{
            xtype: 'tool',
            type: 'gear',
            handler: function(e, target, panelHeader, tool) {
                var portlet = panelHeader.ownerCt;
                portlet.setLoading('Working...');
                Ext.defer(function() {
                    portlet.setLoading(false);
                }, 2000);
            }
        }];
    },

    initComponent: function() {
        var content = '<div class="portlet-content">' + Ext.example.shortBogusMarkup + '</div>';
        Ext.apply(this, {
            id: 'app-viewport',
            layout: {
                type: 'border',
                padding: '0 5 5 5'
            },
            items: [{
                id: 'app-header',
                xtype: 'box',
                region: 'north',
                height: 70,
                html: 'Dimestore Reports'
            }, {
                xtype: 'container',
                region: 'center',
                layout: 'border',
                items: [{
                    id: 'app-portal',
                    xtype: 'portalpanel',
                    region: 'center',
                    items: [

                        {
                            id: 'col-1',
                            items: [{
                                    id: 'portlet-1',
                                    title: 'google',
                                    tools: this.getTools(),
                                    items: {}, //I want ExtJs Form here.
                                    listeners: {
                                        'close': Ext.bind(this.onPortletClose, this)
                                    }
                                },
                                {
                                    id: 'portlet-2',
                                    title: 'grid',
                                    tools: this.getTools(),
                                    html: content,
                                    listeners: {
                                        'close': Ext.bind(this.onPortletClose, this)
                                    }
                                }
                            ]
                        }
                    ]
                }]
            }]
        });
        this.callParent(arguments);
    },
    onPortletClose: function(portlet) {
        this.showMsg('"' + portlet.title + '" was removed');
    },
    showMsg: function(msg) {
        var el = Ext.get('app-msg'),
            msgId = Ext.id();
        this.msgId = msgId;
        el.update(msg).show();
        Ext.defer(this.clearMsg, 3000, this, [msgId]);
    },
    clearMsg: function(msgId) {
        if (msgId === this.msgId) {
            Ext.get('app-msg').hide();
        }
    }
});

请帮帮忙

谢谢

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2012-05-11 19:09:34

我知道答案了

我只是将gmap放在库中的Ext.ux.GMapPanel中并创建一个gmappanel

代码语言:javascript
复制
Ext.create('Ext.ux.GMapPanel', {
    autoShow: true,
    layout: 'fit',
    closeAction: 'hide',
    height: 300,
    border: false,
    items: {
        xtype: 'gmappanel',
        center: {
            geoCodeAddr: 'pune,maharashtra',
            marker: {
                title: 'Pune'
            }
        },

    }
});

使用上面的代码

谢谢

票数 5
EN

Stack Overflow用户

发布于 2015-07-06 19:53:14

另一种解决方案可以是创建自定义组件。我已经创建了一个简单的fiddle here

代码语言:javascript
复制
Ext.define('MyApp.view.Map', {
    extend : 'Ext.Component',
    alias : 'widget.map',

    config : {
        /**
         *
         * @cfg {Object} mapConfig
         * The map specific configurations as specified 
         * in the the [Google Maps JavaScript API][googleMaps]
         * 
         * [googleMaps]: https://developers.google.com/maps/documentation/javascript/3.exp/reference#MapOptions
         */
        mapConfig : null
    },

    /**
     *
     * @property {google.maps.Map} map
     * The google map.
     */
    map : null,

    afterRender : function () {
        var me = this,
            mapConfig = me.getMapConfig();

        me.map = me.createGoogleMap({
            domEl : me.getEl().dom,
            mapConfig : mapConfig
        });
    },

    /**
     *
     * @method createGoogleMap
     * This method creates a new Google map based on the defined
     * configuration. 
     * 
     * @param {Object} config
     * The configuration can contain the following
     * key-value-pairs:
     * 
     *  - domEl {Node} The node do draw the map into.
     *  - mapConfig {Object} The map configuration as specified in the
     *    Google Maps JavaScript API 
     * 
     * @return {google.maps.Map}
     *
     * @throws {Error} Throws an error if the Google library is not
     * loaded.
     */
    createGoogleMap : function (config) {
        if (typeof google === 'undefined') {
            throw new Error('The google library is not loaded.');           
        } else {
            return new google.maps.Map(
                config.domEl,
                config.mapConfig
            );            
        }
    }
});
票数 4
EN

Stack Overflow用户

发布于 2016-05-26 23:07:16

有时,ExtJS的gmap可能不符合要求。在这种情况下,您可以尝试以下方法。

对于视图,您可以将面板放置在任何位置。

代码语言:javascript
复制
{
  xtype: 'panel',
  itemId: 'googleMap',
  height: 500
}

在控制器内部,使用以下方法链接面板和google地图,然后您可以使用google地图API中的所有函数。

代码语言:javascript
复制
var map = new google.maps.Map(this.getView().query('#googleMap')[0].body.dom,{
        center: ,
        zoom: ,
        mapTypeId:google.maps.MapTypeId.ROADMAP
    });
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10482094

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档