function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { if (oldonload) { oldonload(); } func(); } } } /** * @author Marco Alionso Ramirez, marco@onemarco.com * @url http://onemarco.com * @version 1.0 * This code is public domain */ /** * The Tooltip class is an addon designed for the Google Maps GMarker class. * @constructor * @param {GMarker} marker * @param {String} text * @param {Number} padding */ function Tooltip(marker, text, padding){ this.marker_ = marker; this.text_ = text; this.padding_ = padding; } Tooltip.prototype = new GOverlay(); Tooltip.prototype.initialize = function(map){ var div = document.createElement("div"); div.appendChild(document.createTextNode(this.text_)); div.className = 'tooltip'; div.style.position = 'absolute'; div.style.visibility = 'hidden'; div.style.backgroundColor = '#FFFFFF'; div.style.fontWeight = 'bold'; div.style.width = '200px'; div.style.height = '22px'; div.style.padding = '2px'; div.style.border = '1px solid #000'; div.style.textAlign = 'center'; map.getPane(G_MAP_FLOAT_PANE).appendChild(div); this.map_ = map; this.div_ = div; } Tooltip.prototype.remove = function(){ this.div_.parentNode.removeChild(this.div_); } Tooltip.prototype.copy = function(){ return new Tooltip(this.marker_,this.text_,this.padding_); } Tooltip.prototype.redraw = function(force){ if (!force) return; var markerPos = this.map_.fromLatLngToDivPixel(this.marker_.getPoint()); var iconAnchor = this.marker_.getIcon().iconAnchor; var xPos = Math.round(markerPos.x - this.div_.clientWidth / 2); var yPos = markerPos.y - iconAnchor.y - this.div_.clientHeight - this.padding_; this.div_.style.top = yPos + 'px'; this.div_.style.left = xPos + 'px'; } Tooltip.prototype.show = function(){ this.div_.style.visibility = 'visible'; } Tooltip.prototype.hide = function(){ this.div_.style.visibility = 'hidden'; } function initializeAllHouses(id) { addLoadEvent(function() { initializeAllHousesFunc(id); }); } function initializeAllHousesFunc(id) { if (GBrowserIsCompatible() && !=0) { var map = new GMap2(document.getElementById(id), { mapTypes:[G_HYBRID_MAP] }); map.setCenter(new GLatLng(43.28640374, 2.70071491924), 5); map.setUIToDefault(); // Create a base icon for all of our markers that specifies the // shadow, icon dimensions, etc. var baseIcon = new GIcon(G_DEFAULT_ICON); baseIcon.image = "http://www.kuypersverhuur.nl/images/icons/home.png"; baseIcon.iconSize = new GSize(32, 37); baseIcon.shadowSize = new GSize(0,0); var bounds = new GLatLngBounds(); // Creates a marker whose info window displays the letter corresponding // to the given index. function createMarker(point, html, tooltiptext) { var marker = new GMarker(point, baseIcon); bounds.extend(point); GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(html); }); var tooltip = new Tooltip(marker,tooltiptext,0); marker.tooltip = tooltip; map.addOverlay(tooltip); GEvent.addListener(marker,'mouseover',function(){ this.tooltip.show(); }); GEvent.addListener(marker,'mouseout',function(){ this.tooltip.hide(); }); return marker; } // Add 10 markers to the map at random locations map.setZoom(map.getBoundsZoomLevel(bounds)); map.setCenter(bounds.getCenter()); }else{ document.getElementById(id).style.display = 'none'; document.getElementById(id).style.height = '0px'; } }