/**
* CHZERO.Layer.ZeroMapMarkers<br/>
*
* @class ZeroMapMarkers
* @extends OpenLayers.Layer.Markers
* @constructor
* @namespace CHZERO.Layer
* @param {String} name
* @param {Object} options 레이어 옵션 hashtable
*/
CHZERO.Layer.ZeroMapMarkers = OpenLayers.Class(OpenLayers.Layer.Markers,{
CLASS_NAME: 'CHZERO.Layer.ZeroMapMarkers',
/**
* id 와 일치하는 marker 반환. 없을 시 null 반환.
* @method getMarkerById
* @param {String} id marker id
* @return {OpenLayers.Marker} marker 또는 null
*/
getMarkerById: function(match) {
var marker = null;
for (var i = 0, len = this.markers.length; i < len; ++i) {
if (this.markers[i].id == match) {
marker = this.markers[i];
break;
}
}
return marker;
},
/**
* 마커 모두 지우기
* @method removeAllMarker
*/
removeAllMarker: function() {
if (this.markers != null) {
while (this.markers.length > 0) {
this.removeMarker(this.markers[0]);
}
}
},
getMarkersByElementId: function(match) {
var marker = null;
for (var i = 0, len = this.markers.length; i < len; ++i) {
if (this.markers[i].events.element.id == match) {
marker = this.markers[i];
break;
}
}
return marker;
},
removeMarker: function(marker) {
if (this.markers && this.markers.length) {
feat = marker.feature;
if (feat != null) {
feat.layer = null;
feat.id = null;
feat.lonlat = null;
feat.data = null;
if (feat.popup != null) {
if (this.map) {
this.map.removePopup(feat.popup);
}
feat.destroyPopup();
}
marker.feature = null;
feat.marker = null;
}
OpenLayers.Util.removeItem(this.markers, marker);
marker.destroy();
}
},
clearMarkers: function() {
if (this.markers != null) {
var marker = null;
while (this.markers.length > 0) {
this.removeMarker(this.markers[0]);
}
marker = null;
}
}
});