PDA

View Full Version : Help with GMAP with dynamic locations



KernelPanik
23 Sep 2009, 5:36 AM
I have a map that is created when the map icon (on a tree) is clicked. The locations that show are based on where in the tree the map is located (I have multiple map icons, think of a map icon per project, each project has multiple locations different from the other projects)
I can get the locations to show but not the title.
Relevant code.


var myMarkers = [];
var myGeo = [];
var myTitle = [];
proj_map_store.each(function(r) {
var mySWTF= Ext.getCmp('myMap');
myGeo[0] = r.get('address') + ', ' + r.get('city') + ' ' + r.get('state') + ' ' + r.get('zip');
myTitle[0] = r.get('title');
myMarkers.push(myGeo,myTitle);
mySWTF.addMarkers(myMarkers);
});

Like I said the locations make it on the map, but I can't figure out how to get them to have a title. The code above is just one of my attempts. I have searched the FAQs and forms repeatedly to no avail. If I missed something obvious, feel free to flame...but try and be helpful too. :)
NOTE: The myTitle doesn't do anything.

Thanks

KernelPanik
29 Sep 2009, 6:52 AM
Bueller...Bueller...

VinylFox
28 Nov 2009, 8:02 AM
Your code is quite confusing...why are myGeo and myTitle arrays? and why are you adding to the first item in those arrays and pushing them into another array?

addMarkers takes an array of objects, not an array of arrays.

It should look something like this:

[{
lat: 42.339641,
lng: -71.094224,
marker: {title: 'Boston Museum of Fine Arts'}
},{
lat: 42.339419,
lng: -71.09077,
marker: {title: 'Northeastern University'}
}]

Notice that the title is part of the nested marker object, not the main object.