I have a panto marker function which requires the longitude and latitude variables. I have the ability to send the contact name as a variable.
The contact name is the tag for the marker i want to pan to. Is it possible for me to get the longitude and latitude of the marker by tag?
Here is my panto function
function pantoUser(lati,longi,i)
{
jQuery("#dispatcher").gmap3({
action: 'panTo',
args:[new google.maps.LatLng(lati,longi)],
zoom: 7
});
currentPoint = i;
jQuery("#dispatcher").css({
cursor: 'pointer'
});
jQuery('#markerTitle' + i + '').fadeIn({
duration: 200,
queue: false
}).animate({
bottom: "32px"
}, {
duration: 200,
queue: false
});
jQuery("#target").stop(true, true).fadeIn(1200).delay(500).fadeOut(1200);
jQuery("#dispatcher").css({
cursor: 'default'
});
jQuery('#markerTitle' + i + '').stop(true, true).fadeOut(2000, function() {
jQuery("#dispatcher").css({
bottom: "0"
})
jQuery("#target").stop(true, true).fadeIn(1200).delay(500).fadeOut(1200);
});
}
I was thinking of something like this?
function locateLastSpeaker(name) {
var lati = SOMEHOW GET IT
var longi = SOMEHOW GET IT
pantoUser(lati,longi,1)
}
EDIT after trying duncans solution!!
var stuMarkers = {};
function addMarker(i, lati, longi, id, name, state, datestring) {
var placename = name;
stuMarkers[placename].lat = lati;
stuMarkers[placename].lng = longi;
$('#dispatcher').gmap3(
{ action: 'addMarker', ....etc
Instead of an array as barry suggests, what about an object, keyed on the name. That way you won’t even have to loop.