Reputation: 3
I have a map with a marker, and i want to make the marker clicktable to show some basic info.
I am new to Sencha, and I need advice what should I implemante in listener function to get the same effect as i click on list item:
for example, this is my code of maprender function
var lat = 37.428607;
var lng = -122.169344;
var latLng = new google.maps.LatLng(lat, lng);
var marker = new google.maps.Marker({
position: latLng,
map: gmap,
draggable: false,
animation: google.maps.Animation.DROP,
title: 'cool'
});
var contentString = 'bla bla bla';
var infowindow = new google.maps.InfoWindow({
content: contentString
});
google.maps.event.addListener(marker, 'click', function() {
/* here comes something that will make my detail list visible with the marker details*/
});
and i want to make it work in the same way as my function for "itemtap" which i use in my list... something like this:
onMyListItemTap: function(dataview, index, target, record, e, options) {
this.setActiveItem('detalji');this.down('#back').show();
this.down('#detalji').setData(record.data);
}
Upvotes: 0
Views: 1039
Reputation: 423
There is a great example on Github for Sencha Touch 1...I believe it's called World Map. If you unzip that (the app is in one of the many folders) you can see a Google map wil multiple custom markers. This project is very useful for learning, as it not only shows custom map markers, but also popup overlays on a marker click.
I have yet to adapt it to Sencha Touch 2, but it shouldn't be too difficult...here is some example code (after multiple markers have been added):
google.maps.event.addListener(marker, 'click', function()
{
if (!this.popup)
{
this.popup = new Ext.Panel(
{
floating: true,
modal: true,
centered: true,
width: 500,
styleHtmlContent: true,
scroll: 'vertical',
items:[{
xtype:'button',
ui:'round',
text:'See Country Profile',
handler:goToCountryWrapper,
scope : this
},
(new countryOverlay(country)).overlayPanel
],
layout: {
type: 'auto',
padding: '55',
align: 'left'
},
dockedItems: [{
dock: 'top',
xtype: 'toolbar',
title: country.title
}],
});
};
this.popup.show('pop');
});
Also I think from what I understand about Sencha Touch 2, you would have to put a listener in your map controller (MyApp.map.controller file)....read up about the refs, as the refs 'finds' the marker(s) you have defined and adds a listener to the item.
If you have any progress please post your findings :-)
Upvotes: 0