Skip to content

Commit

Permalink
Changed component lookups to be a bit nicer.
Browse files Browse the repository at this point in the history
  • Loading branch information
kazmiekr committed Jun 4, 2013
1 parent 3574c25 commit 0432dff
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 68 deletions.
127 changes: 66 additions & 61 deletions sampleapp/view/SampleView.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,69 +9,74 @@ Ext.define('SampleApp.view.SampleView', {
pack: 'start',
align: 'stretch'
},
items:[
{
xtype: 'panel',
flex: 1,
layout: 'fit',
tbar: [
{
xtype: 'button',
text: 'Boston',
listeners:{
click: function(){
var map = this.up('panel').down('leafletmapview');
map.getMap().setView([42.3583, -71.0603], 13);
initComponent: function(){
var me = this;
this.items = [
{
xtype: 'panel',
flex: 1,
layout: 'fit',
tbar: [
{
xtype: 'button',
text: 'Boston',
listeners:{
click: function(){
me.updateMapLocation([42.3583, -71.0603], 13);
}
}
}
},
{
xtype: 'button',
text: 'Buffalo',
listeners:{
click: function(){
var map = this.up('panel').down('leafletmapview');
map.getMap().setView([42.8864, -78.8786], 13);
},
{
xtype: 'button',
text: 'Buffalo',
listeners:{
click: function(){
me.updateMapLocation([42.8864, -78.8786], 13);
}
}
}
},
{
xtype: 'button',
text: 'NYC',
listeners:{
click: function(){
var map = this.up('panel').down('leafletmapview');
map.getMap().setView([40.7142, -74.0064], 13);
},
{
xtype: 'button',
text: 'NYC',
listeners:{
click: function(){
me.updateMapLocation([40.7142, -74.0064], 13);
}
}
}
}
],
items:[
{
itemId: 'locationmap',
xtype: 'leafletmapview',
initialLocation: [39.50, -98.35],
initialZoomLevel: 3
}
]
},
{
xtype: 'splitter',
size: 10
},
{
xtype: 'panel',
title: 'Current Location',
titleAlign: 'center',
layout: 'fit',
flex: 1,
items: [
{
xtype: 'leafletmapview',
useCurrentLocation: true,
tileLayerStyle: 33332
}
]
}
]
],
items:[
{
itemId: 'locationmap',
xtype: 'leafletmapview',
initialLocation: [39.50, -98.35],
initialZoomLevel: 3
}
]
},
{
xtype: 'splitter',
size: 10
},
{
xtype: 'panel',
title: 'Current Location',
titleAlign: 'center',
layout: 'fit',
flex: 1,
items: [
{
xtype: 'leafletmapview',
useCurrentLocation: true,
tileLayerStyle: 33332
}
]
}
];
this.callParent(arguments);
},
updateMapLocation: function(location, zoom){
var map = this.query('#locationmap')[0];
map.getMap().setView(location, zoom);
}
});
14 changes: 7 additions & 7 deletions ux/LeafletMapView.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ Ext.define('Ext.ux.LeafletMapView', {
tileMaxZoom: 18,
attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, Imagery © <a href="http://cloudmade.com">CloudMade</a>'
},
initComponent: function(){
this.callParent(arguments);
},
afterRender: function(t, eOpts){
this.callParent(arguments);

Expand All @@ -25,8 +22,10 @@ Ext.define('Ext.ux.LeafletMapView', {
var map = L.map(this.getId());
this.setMap(map);

if (this.getInitialLocation() && this.getInitialZoomLevel()){
map.setView(this.getInitialLocation(), this.getInitialZoomLevel());
var initialLocation = this.getInitialLocation();
var initialZoomLevel = this.getInitialZoomLevel();
if (initialLocation && initialZoomLevel){
map.setView(initialLocation, initialZoomLevel);
} else {
map.fitWorld();
}
Expand All @@ -47,8 +46,9 @@ Ext.define('Ext.ux.LeafletMapView', {
},
onResize: function(w, h, oW, oH){
this.callParent(arguments);
if (this.getMap()){
this.getMap().invalidateSize();
var map = this.getMap();
if (map){
map.invalidateSize();
}
}
});

0 comments on commit 0432dff

Please sign in to comment.