Reputation: 75955
I've created a new sencha app with the sencha-cmd. I'm a bit new to this. So i've tried to create a map:
{
title: 'Map',
iconCls: 'locate',
layout: 'card',
useCurrentLocation: false,
fullscreen: false,
id: 'locationmap',
mapOptions: {
zoom: 12,
center : new google.maps.LatLng(37.381592, -122.135672),
navigationControl: true,
navigationControlOptions:
{
style: google.maps.NavigationControlStyle.DEFAULT
}
},
items: [
{
docked: 'top',
xtype: 'titlebar',
title: 'Getting Started'
},
{
xtype: 'map'
}
]
}
I've included the necessary google maps api files, and also required Ext.Map
However the map isn't centering on 37.381592, -122.135672, its centering elsewhere. How can I fix this?
Additionally, how can I access the maps object? So I can call stuff like .getCenter()
Upvotes: 2
Views: 1707
Reputation: 13273
Not sure on the centering, but you could do it after the fact with:
theView.setMapCenter({latitude: 37.381592, longitude: -122.135672});
As for getting the element, you can simply call:
theView.getMap();
This is all coming from the Sencha Touch 2 docs, FYI. I'm interested to see how it works out, I'll be implementing a map in my new app soon.
EDIT:
Looking at it more closely, shouldn't your mapOptions
parameter be on the xtype: 'map'
item?
...
{
xtype: 'map',
useCurrentLocation: false,
mapOptions: {
zoom: 12,
center : new google.maps.LatLng(37.381592, -122.135672),
navigationControl: true,
navigationControlOptions:
{
style: google.maps.NavigationControlStyle.DEFAULT
}
}
}
...
Upvotes: 1