// EgyptMarker var EgyptMarker = Class.create(); EgyptMarker.prototype = { map: false, marker: false, text: false, ext: false, type: 0, geoLat: 0, geoLong: 0, eventListenerClick: false, eventListenerMouseout: false, initialize: function(geoLat, geoLong, map, mmanager, type, text, ext, showExt) { this.text = text; this.type = type; this.geoLat = geoLat; this.geoLong = geoLong; this.ext = ext; this.map = map; this.marker = new GMarker(new GLatLng( geoLat, geoLong ), {icon: mmanager.getIcon(type)} ); this.marker.egyptemarker = this; // events GEvent.addListener(this.marker,"mouseover", function() { this.showTooltip(); }.bind(this) ); if (showExt) this.showExtend(); }, showExtend: function () { $('mapExt').hide(); if (this.type < 4) $('mapExt').className = 'mapExtDest'; else $('mapExt').className = 'mapExtInfo'; $('mapExttext').innerHTML = '' + this.ext; var point = map.getCurrentMapType().getProjection().fromLatLngToPixel(map.getBounds().getSouthWest(), map.getZoom()); var offset = map.getCurrentMapType().getProjection().fromLatLngToPixel(this.marker.getPoint(), map.getZoom()); var pos = new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(offset.x - point.x, -offset.y + point.y )); pos.apply($('mapExt')); Effect.Appear( $('mapExt') , {duration: 0.3}); }, showTooltip: function () { $('mapTT').hide(); if (this.type < 4) $('mapTT').className = 'mapTTDest'; else $('mapTT').className = 'mapTTInfo'; $('mapTTtext').innerHTML = this.text; $('mapTTicon').setStyle( {backgroundImage: 'url(http://assets.egypte.nl/site/layout/map/iconT'+ this.type +'.png)'} ); this.eventListenerClick = this.clickTooltip.bindAsEventListener(this); this.eventListenerMouseout = this.hideTooltip.bindAsEventListener(this); $('mapTT').observe('click', this.eventListenerClick); $('mapTT').observe('mouseout', this.eventListenerMouseout); var point = map.getCurrentMapType().getProjection().fromLatLngToPixel(map.getBounds().getSouthWest(), map.getZoom()); var offset = map.getCurrentMapType().getProjection().fromLatLngToPixel(this.marker.getPoint(), map.getZoom()); var pos = new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(offset.x - point.x, -offset.y + point.y )); pos.apply($('mapTT')); Effect.Appear( $('mapTT') , {duration: 0.3}); }, hideTooltip: function() { $('mapTT').stopObserving('click', this.eventListenerClick); $('mapTT').stopObserving('mouseout', this.eventListenerMouseout); $('mapTT').hide(); }, clickTooltip: function() { if (this.type == 1) { this.map.setCenter(new GLatLng( this.geoLat, this.geoLong), 5); } if (this.type == 2) { this.map.setCenter(new GLatLng( this.geoLat, this.geoLong), 10); } if (this.type == 3) { this.showExtend(); } } } // EgyptMarkerManager var EgyptMarkerManager = Class.create(); EgyptMarkerManager.prototype = { markers : [], markerManager : null, map : null, icons : [], initialize: function(map) { this.markerManager = new MarkerManager(map); // Tooltip if ($('mapTT')) { $('mapTT').hide(); $('map_canvas').appendChild($('mapTT')); } // Extend if ($('mapExt')) { $('mapExt').hide(); $('map_canvas').appendChild( $('mapExt') ); } GEvent.addListener(map, "movestart", function() { $('mapExt').hide(); $('mapTT').hide(); } ); GEvent.addListener(map, "zoomend", function() { $('mapExt').hide(); $('mapTT').hide(); } ); }, add : function(marker) { this.markers.push(marker); }, getMarkersByType : function(type) { var result = []; var resulti = 0; this.markers.each(function(emarker) { if (emarker.type == type) result[resulti++] = emarker.marker; } ); return result; }, addMarkersToMap : function() { // type 1 this.markerManager.addMarkers(this.getMarkersByType(1), 1, 4); // type 2 this.markerManager.addMarkers(this.getMarkersByType(2), 5, 8); // type 3 this.markerManager.addMarkers(this.getMarkersByType(3), 9, 15); // type 4 this.markerManager.addMarkers(this.getMarkersByType(4), 9, 15); this.markerManager.refresh(); }, getIcon : function(type) { if (!this.icons[type]) { var icon = new GIcon(); icon.image = 'http://assets.egypte.nl/site/layout/map/iconT'+ type +'.png'; icon.iconAnchor = new GPoint(0, 28); icon.infoWindowAnchor = new GPoint(0, 28); icon.iconSize = new GSize(25, 28); this.icons[type] = icon; } return this.icons[type]; } }