/**
 * Marker structure for the "Find Nearby" map search
 */
function NearbyMarker(map){
	this.map = map
	this.isDirectHit = false;
	this.marker = 0;
	this.markerCoords = 0;
}

NearbyMarker.prototype = new Object();

NearbyMarker.prototype.setDirectHit = function(val) {
	this.isDirectHit = val;
}

NearbyMarker.prototype.setCoords = function(val) {
	this.markerCoords = val;
}

/**
 * Generates the GIcon instance depending on the searched address hit (direct hit, or closest address match)
 */
NearbyMarker.prototype.makeIcon = function() {
	var icon = new GIcon();
	if (this.isDirectHit){
		// direct hit marker
		icon.image = "/images/icons/find_nearby_hit.png";
		icon.iconSize = new GSize(14, 14);
		icon.iconAnchor = new GPoint(7, 7);
	} else {
		// you are here pointer
		icon.image = "/images/icons/you-are-here.png";
		icon.iconSize = new GSize(20, 30);
		icon.iconAnchor = new GPoint(10, 30);
	}
	return icon;
}

/**
 * Shows marker (add to the map)
 */
NearbyMarker.prototype.show = function() {
	if (this.marker != 0) {
		this.marker.remove();
	}
	this.marker = new GMarker(this.markerCoords, { icon: this.makeIcon(), clickable: false });
	this.map.addOverlay(this.marker);
}
