// places handler function NewPlaces(mapi) { var objplaces = new Object(); objplaces.displayplaces = true; objplaces.lastzoom = -1; objplaces.mapi = mapi; objplaces.places = new Array(); objplaces.info = null; objplaces.showPlaces = function() { this.displayplaces = true; this.recheckLevels(); } objplaces.hidePlaces = function() { this.displayplaces = false; this.recheckLevels(); } objplaces.flipPlaces = function() { if (this.displayplaces) { this.hidePlaces(); } else { this.showPlaces(); } } objplaces.createPlaceItem = function(item) { p = new Array(); p.data = item; p.data.pos = new google.maps.LatLng(p.data.gpslat, p.data.gpslng); p.marker = this.mapi.markers.markers[this.mapi.markers.CreatePlaceMarker(this, p.data)]; //this.mapi.gmap.addOverlay(p.marker); p.marker.setMap(this.mapi.gmap); if ((this.lastzoom < p.data.fromzoom) || (!this.displayplaces)) { p.marker.setVisible(false); //p.marker.hide(); } return p; } objplaces.destroyPlaceItem = function(item) { //this.mapi.gmap.removeOverlay(item.marker); item.marker.setMap(null); } objplaces.refreshPlacesFromArray = function(places) { tmpplaces = new Array(); for (ti = 0; ti < places.length; ti++) { tmpplaces[ti] = this.createPlaceItem(places[ti]); } for (ti = 0; ti < this.places.length; ti++) { this.destroyPlaceItem(this.places[ti]); } this.places = tmpplaces; } objplaces.reqLoadPlacesError = function() { } objplaces.reqLoadPlacesComplete = function() { } objplaces.reqLoadPlacesSuccess = function(data) { if (!data.error) { this.refreshPlacesFromArray(data.places); } else alert(data.errordesc); } objplaces.loadPlaces = function() { var url = 'http://www.kamennimuzici.cz/mapa/places.php'; var params = {op:'getplaces', area:'all'}; jQuery.ajax({cache:false, context:this, data:params, dataType:'json', error:this.reqLoadPlacesError, success:this.reqLoadPlacesSuccess, complete:this.reqLoadPlacesComplete, url:url, type:'POST'}); } objplaces.reloadPlaces = function() { } objplaces.recheckLevels = function() { if (this.places.length) { for (ti = 0; ti < this.places.length; ti++) { if ((this.places[ti].data.fromzoom <= this.lastzoom) && (this.displayplaces)) { //this.places[ti].marker.show(); this.places[ti].marker.setVisible(true); } else { //this.places[ti].marker.hide(); this.places[ti].marker.setVisible(false); } } } } objplaces.reloadTimerCallback = (function(obj, meth) { return function () { meth.call(obj); } })(objplaces, objplaces.reloadPlaces); objplaces.setReloadTimeout = function(what) { if (what == 'zoom') { intr = 1000; } else { intr = 500; } if (this.reloadtimer != null) { clearTimeout(this.reloadtimer); } callback = function (obj, meth) { f = function () { } f.obj = obj; f.meth = meth; return f; } this.reloadtimer = setTimeout(objplaces.reloadTimerCallback, intr); } objplaces.onMapChange = function() { zoom = this.mapi.gmap.getZoom() if (this.lastzoom != zoom) { this.lastzoom = zoom; this.recheckLevels(); this.setReloadTimeout('zoom'); } else { this.setReloadTimeout('pos'); } } objplaces.onResultMouseOver = function(item) { this.mapi.markers.markers[item.idmarker].setIcon(icourls.placeSel); this.showInfo(item); } objplaces.onResultMouseOut = function(item) { this.mapi.markers.markers[item.idmarker].setIcon(icourls.place); this.clearInfos(); } objplaces.onResultClick = function(item) { this.openPlaceDetail(this.mapi.markers.markers[item.idmarker].idplace); } objplaces.openPlaceDetail = function(id) { this.loadDetail(id); } objplaces.reqLoadDetailError = function() { } objplaces.reqLoadDetailComplete = function() { } objplaces.reqLoadDetailSuccess = function(data) { if (!data.error) { this.displayDetail(data); } else alert(data.errordesc); } objplaces.loadDetail = function(id) { var url = 'http://www.kamennimuzici.cz/mapa/places.php'; var params = {op:'getdetail', id:id}; jQuery.ajax({cache:false, context:this, data:params, dataType:'json', error:this.reqLoadDetailError, success:this.reqLoadDetailSuccess, complete:this.reqLoadDetailComplete, url:url, type:'POST'}); } objplaces.displayDetail = function(data) { //iw = this.mapi.gmap.getInfoWindow(); label = data.detail.name; cont = '

' + data.detail.name + '

' + ((data.detail.picture.length)?('-'):('')) + data.detail.desc + '
Web: ' + data.detail.urltext + '
'; //tab = new GInfoWindowTab(label, cont); //iw.reset(new google.maps.LatLng(data.detail.gpslat, data.detail.gpslng), [tab], new google.maps.Size(400, 200)); //pt = this.mapi.gmap.fromLatLngToContainerPixel(new google.maps.LatLng(data.detail.gpslat, data.detail.gpslng)); //pt.y-= 70; //this.mapi.gmap.panTo(this.mapi.gmap.fromContainerPixelToLatLng(pt)); //iw.show(); iw = new google.maps.InfoWindow({ content: cont, position: new google.maps.LatLng(data.detail.gpslat, data.detail.gpslng) }); iw.open(this.mapi.gmap); } objplaces.showInfo = function (item) { this.infoLine.reset(item.pos, item.name); this.infoLine.draw(true); this.infoLine.show(); } objplaces.clearInfos = function () { this.infoLine.hide(); } objplaces.initializeInfo = function() { function PlaceItemDesc(map) { this.t_label = ''; this.t_pos = new google.maps.LatLng(0, 0); this.map_ = map; this.div_ = null; } PlaceItemDesc.prototype = new google.maps.OverlayView(); PlaceItemDesc.prototype.reset = function(pos, label) { this.t_label = label; this.t_pos = pos; } PlaceItemDesc.prototype.show = function() { this.div_.style.display = "block"; } PlaceItemDesc.prototype.hide = function() { this.div_.style.display = "none"; } PlaceItemDesc.prototype.onAdd = function() { var div = document.createElement("div"); div.style.position = "absolute"; div.style.display = "none"; var panes = this.getPanes(); panes.floatPane.appendChild(div); //map.getPane(G_MAP_FLOAT_PANE).appendChild(div); this.map_ = map; this.div_ = div; } PlaceItemDesc.prototype.onRemove = function() { this.div_.parentNode.removeChild(this.div_); } PlaceItemDesc.prototype.copy = function() { return new PlaceItemDesc(this.mapi.gmap); } PlaceItemDesc.prototype.draw = function(force) { if (!force) return; var overlayProjection = this.getProjection(); var posxy = overlayProjection.fromLatLngToDivPixel(this.t_pos); var name = this.t_label.replace(/&/g, "&").replace(/>/g, ">").replace(/ 300) { pos+= 'right: 20px; '; } else { pos+= 'left: 20px; '; } if (posxy.y > 250) { pos+= 'bottom: 20px; '; } else { pos+= 'top: -20px; '; } this.div_.innerHTML = "
" + name + "
"; } this.infoLine = new PlaceItemDesc(this.mapi.gmap); this.infoLine.setMap(this.mapi.gmap); //this.mapi.gmap.addOverlay(this.infoLine); } objplaces.initialize = function() { this.loadPlaces(); this.hndzoomend = google.maps.event.bind(this.mapi.gmap, "zoom_changed", this, this.onMapChange); this.hndmove = google.maps.event.bind(this.mapi.gmap, "dragend", this, this.onMapChange); this.initializeInfo(); this.onMapChange(); } return objplaces; }