Я строю параметры для плагина gMap динамически, и мне нужно знать, как проверить, существует ли один из маркеров.
Вот как это строится в JavaScript:
success: function(data) {
var markers = { controls: true, scrollwheel: true, markers: [], zoom: 8 };
$.each(data["events"], function(id, event) {
// .. do other stuff with the data
if(showmap) {
// add location to maps list prevent multiples
//
// How do I check to see if it already exists?
//
// event[] is a JSON Object, BTW
//
//if((markers.indexOf(event['LocLatitude']) == -1) && (markers.indexOf(event['LocLongitude']) == -1)) {
marker1 = { latitude: event['LocLatitude'],
longitude:event['LocLongitude'],
html: '"'+event['LocName']+'<br />'+event['LocAddress']+'<br />'+event['LocCity']+', '+event['LocState']+'"',
icon:{image: "/images/gmap_pin_orange.png",
iconsize: [26, 46],
iconanchor: [12,46],
infowindowanchor: [12, 0]
}
};
markers.markers.push(marker1);
//} // if((markers.indexOf(event['LocLatitude']) == -1)
} // if(showmap)
} // $.each(data["events"]
}, // success:
Код с комментариями выше показывает, как я делал это, когда строил его как строку, эта техника больше не работает.
Мне нужно знать, как проверить, существует ли уже добавляемый маркер в markers.markers до его нажатия.