从我的地图更改样式

时间:2017-03-11 17:53:25

标签: javascript google-maps extjs

我正在学习如何使用Ext.js框架,并且我正在使用MVVM模型构建简单的应用程序。我构建了一个简单的地图,我试图将其成本化,我使用Google API和GMapPanel小部件做了一个应用程序,现在我想创建一个新的样式并添加它但我有一些问题加入我的服装风格。

我收到以下错误:

  

未捕获的TypeError:无法读取属性' set'未定义的       在constructor.init(MapController.js?_dc = 20151109082919:198)       在新构造函数(ext-all-rtl-debug.js?_dc = 20151109082919:63176)       在构造函数[as self](ext-all-rtl-debug.js?_dc = 20151109082919:12296)       在Object.widget(ext-all-rtl-debug.js?_dc = 20151109082919:14662)       在constructor.create(ext-all-rtl-debug.js?_dc = 20151109082919:26228)       在constructor.lookupComponent(ext-all-rtl-debug.js?_dc = 20151109082919:123938)       在constructor.prepareItems(ext-all-rtl-debug.js?_dc = 20151109082919:124418)       在constructor.add(ext-all-rtl-debug.js?_dc = 20151109082919:123436)       在constructor.initItems(ext-all-rtl-debug.js?_dc = 20151109082919:123861)       在constructor.initComponent(ext-all-rtl-debug.js?_dc = 20151109082919:123821)

我的代码:

Output display = new Output();

1 个答案:

答案 0 :(得分:2)

您只需将样式数组添加到gmappanel mapOptions对象:

{
    region: 'center',
    xtype: 'gmappanel',
    gmapType: 'map',
    center: new google.maps.LatLng(53.419824, -3.0509294),
    mapOptions: {
        mapTypeId: google.maps.MapTypeId.ROADMAP,
        zoom: 15,
        styles: [
            {elementType: 'geometry', stylers: [{color: '#ebe3cd'}]},
            {elementType: 'labels.text.fill', stylers: [{color: '#523735'}]},
            {elementType: 'labels.text.stroke', stylers: [{color: '#f5f1e6'}]},
            {
                featureType: 'administrative',
                elementType: 'geometry.stroke',
                stylers: [{color: '#c9b2a6'}]
            },
            {
                featureType: 'administrative.land_parcel',
                elementType: 'geometry.stroke',
                stylers: [{color: '#dcd2be'}]
            },
            {
                featureType: 'administrative.land_parcel',
                elementType: 'labels.text.fill',
                stylers: [{color: '#ae9e90'}]
            },
            {
                featureType: 'landscape.natural',
                elementType: 'geometry',
                stylers: [{color: '#dfd2ae'}]
            },
            {
                featureType: 'poi',
                elementType: 'geometry',
                stylers: [{color: '#dfd2ae'}]
            },
            {
                featureType: 'poi',
                elementType: 'labels.text.fill',
                stylers: [{color: '#93817c'}]
            },
            {
                featureType: 'poi.park',
                elementType: 'geometry.fill',
                stylers: [{color: '#a5b076'}]
            },
            {
                featureType: 'poi.park',
                elementType: 'labels.text.fill',
                stylers: [{color: '#447530'}]
            },
            {
                featureType: 'road',
                elementType: 'geometry',
                stylers: [{color: '#f5f1e6'}]
            },
            {
                featureType: 'road.arterial',
                elementType: 'geometry',
                stylers: [{color: '#fdfcf8'}]
            },
            {
                featureType: 'road.highway',
                elementType: 'geometry',
                stylers: [{color: '#f8c967'}]
            },
            {
                featureType: 'road.highway',
                elementType: 'geometry.stroke',
                stylers: [{color: '#e9bc62'}]
            },
            {
                featureType: 'road.highway.controlled_access',
                elementType: 'geometry',
                stylers: [{color: '#e98d58'}]
            },
            {
                featureType: 'road.highway.controlled_access',
                elementType: 'geometry.stroke',
                stylers: [{color: '#db8555'}]
            },
            {
                featureType: 'road.local',
                elementType: 'labels.text.fill',
                stylers: [{color: '#806b63'}]
            },
            {
                featureType: 'transit.line',
                elementType: 'geometry',
                stylers: [{color: '#dfd2ae'}]
            },
            {
                featureType: 'transit.line',
                elementType: 'labels.text.fill',
                stylers: [{color: '#8f7d77'}]
            },
            {
                featureType: 'transit.line',
                elementType: 'labels.text.stroke',
                stylers: [{color: '#ebe3cd'}]
            },
            {
                featureType: 'transit.station',
                elementType: 'geometry',
                stylers: [{color: '#dfd2ae'}]
            },
            {
                featureType: 'water',
                elementType: 'geometry.fill',
                stylers: [{color: '#b9d3c2'}]
            },
            {
                featureType: 'water',
                elementType: 'labels.text.fill',
                stylers: [{color: '#92998d'}]
            }
        ]
    }
}