-
6 Dec 2011 3:13 PM #1
Answered: How to place a Google Map side by side with another panel?
Answered: How to place a Google Map side by side with another panel?
Hi.
I am new on Sencha Touch but I am facing a problem. I would like to place Google Maps side by side with another Panel.
How can I achieve this?
I tried the different layouts but without any good results.
Any help will be appreciated.
Thanks
-
Best Answer Posted by rdougan
This works for me in PR2:
Code:Ext.application({ launch: function() { Ext.Viewport.add({ layout: { type: 'hbox', align: 'stretch' }, defaults: { flex: 1 }, items: [ { html: 'html', style: 'background:lightgray' }, { xtype: 'map', getLocation: true, mapOptions: { zoom: 12 } } ] }); } });
Ensure you have the Google Maps API file loaded.
-
6 Dec 2011 3:27 PM #2
Sencha Inc.
Robert Dougan - @rdougan
Sencha Touch 2 and Ext JS 4 Core Team Member, SASS/Theming Wizard.
-
6 Dec 2011 3:33 PM #3
Thanks for your quick reply. I did the following but the map is not being shown:
var map = new Ext.Map({
title: 'Map', // Name that appears on this tab
getLocation: true, // Gets user's current location
mapOptions: { // Used in rendering map
zoom: 12
}
});
Ext.create('Ext.Container', {
fullscreen: true,
layout: 'hbox',
items: [
{
html: 'message list',
style: 'background-color: #5E99CC;',
flex: 1
},
{
items: [map],
flex: 2
}
]
});
-
6 Dec 2011 3:39 PM #4
This works for me in PR2:
Code:Ext.application({ launch: function() { Ext.Viewport.add({ layout: { type: 'hbox', align: 'stretch' }, defaults: { flex: 1 }, items: [ { html: 'html', style: 'background:lightgray' }, { xtype: 'map', getLocation: true, mapOptions: { zoom: 12 } } ] }); } });
Ensure you have the Google Maps API file loaded.Sencha Inc.
Robert Dougan - @rdougan
Sencha Touch 2 and Ext JS 4 Core Team Member, SASS/Theming Wizard.
-
6 Dec 2011 3:41 PM #5
Can you send me the complete code? Thanks a lot
-
6 Dec 2011 3:41 PM #6
-
6 Dec 2011 3:46 PM #7
I have another question. Instead of placing
{
xtype: 'map',
getLocation: true,
mapOptions: {
zoom: 12
}
}
can I refer a variable previously defined (like var mapdemo = Ext.create('Ext.Map', ...)?
-
6 Dec 2011 3:49 PM #8
Yup.
Sencha Inc.
Robert Dougan - @rdougan
Sencha Touch 2 and Ext JS 4 Core Team Member, SASS/Theming Wizard.
-
6 Dec 2011 3:52 PM #9
How can I do that?
When trying to put something like below does not work.
<code>
var map = new Ext.Map({
title: 'Map', // Name that appears on this tab
getLocation: true, // Gets user's current location
mapOptions: { // Used in rendering map
zoom: 12
}
});
Ext.application({
launch: function() {
Ext.Viewport.add({
layout: {
type: 'hbox',
align: 'stretch'
},
defaults: {
flex: 1
},
items: [
{
html: 'html',
style: 'background:lightgray'
},
{
items: [map]
}
]
});
}
});
</code>
-
6 Dec 2011 3:54 PM #10
You do not need to put it inside another items: []. That means that your second panel (on the right side, where the map was before) is now another container, and you are adding the map to that container.
Instead, just do the following:
Notice how I am adding it as an item:Code:Ext.application({ launch: function() { var map = Ext.create('Ext.Map', { getLocation: true, mapOptions: { zoom: 12 } }); Ext.Viewport.add({ layout: { type: 'hbox', align: 'stretch' }, defaults: { flex: 1 }, items: [ { html: 'html', style: 'background:lightgray' }, map ] }); } });
Code:items: [ { html: 'html', style: 'background:lightgray' }, map ]Sencha Inc.
Robert Dougan - @rdougan
Sencha Touch 2 and Ext JS 4 Core Team Member, SASS/Theming Wizard.


Reply With Quote