//////////////////////////////////////////////////// // create a global request object to be used var GoogleMarkers=[]; var GoogleMap; var GoogleDir; var GoogleMgr = null; var GoogleTmpPoint; var GoogleStartPoint=null; var GoogleStopPoint=null; var GoogleOverPoints=[]; var GooglePointHere=null; var OtwartoMape = true; var AntMapRodzaje=null; var AntMapaScrollableLegend = null; var markerTuJestem = null; var GoogleInfoWindow = null; var MouseOverMarker=false; function getLocationsAndMap() { var data = $("#formRodzaje :checkbox"); var ids=""; for(i=0;i0) { obj.scrollable({onSeek: function () { setPageScrollablePanel(); } }); AntMapaScrollableLegend = obj.scrollable(); } } function OdswiezObniektyNaMapie() { var link='ajax.php?mapa,odswiezobiektynamapie,pol,,1'; $.get(link,{},function (json) { ShowObjectsOnMap(json); },"json"); } function SetStartPoint(point) { GoogleStartPoint = point; var marker = createMarker(point,'Start','startowy punkt','start.gif',-1,null,null,null) ; GoogleMap.addOverlay(marker); if(GoogleStopPoint!=null) { var tmparr = Array(GoogleStartPoint,GoogleStopPoint); GoogleDir.loadFromWaypoints(tmparr); } marker=null; } function SetStopPoint(point) { GoogleStopPoint = point; var marker = createMarker(point,'Start','startowy punkt','stop.gif',-2,null,null,null) ; GoogleMap.addOverlay(marker); if(GoogleStartPoint != null) { var tmparr = Array(GoogleStartPoint,GoogleStopPoint); GoogleDir.loadFromWaypoints(tmparr); } marker=null; } function SetFromHerePoint(point) { GoogleStartPoint = GooglePointHere; var marker = createMarker(point,'Start','z punktu startowego','z.gif',-3,null,null,null) ; GoogleStopPoint = point; if(GoogleStopPoint != null) { var tmparr = Array(GoogleStartPoint,GoogleStopPoint); GoogleDir.loadFromWaypoints(tmparr); } marker=null; } function SetToHerePoint(point) { GoogleStartPoint = point; var marker = createMarker(point,'Start','z punktu startowego','z.gif',-3,null,null,null) ; GoogleStopPoint = GooglePointHere; if(GoogleStopPoint != null) { var tmparr = Array(GoogleStartPoint,GoogleStopPoint); GoogleDir.loadFromWaypoints(tmparr); } marker=null; } function handleErrors() { if (GoogleDir.getStatus().code == G_GEO_UNKNOWN_ADDRESS) { alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: " + GoogleDir.getStatus().code); } else if (GoogleDir.getStatus().code == G_GEO_SERVER_ERROR) { alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " + GoogleDir.getStatus().code); } else if (GoogleDir.getStatus().code == G_GEO_MISSING_QUERY) { alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " + GoogleDir.getStatus().code); } else if (GoogleDir.getStatus().code == G_GEO_BAD_KEY) { alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: " + GoogleDir.getStatus().code); } else if (GoogleDir.getStatus().code == G_GEO_BAD_REQUEST) { alert("A directions request could not be successfully parsed.\n Error code: " + GoogleDir.getStatus().code); } else { alert("An unknown error occurred."); } } function onGDirectionsLoad() { } $(document).ready(function() { appendBootstrap(); /* GoogleInfoWindow = new google.maps.InfoWindow({pixelOffset: new google.maps.Size(5,0)}); LoadMap(); OtwartoMape=true; getLocationsAndMap();*/ }); function handleApiReady() { /**********************************ladowanie markerow wlasnych***************************/ window.LabeledMarker = function (latlng, opts) { this.latlng_ = latlng; // Once the LatLng and text are set, add the overlay to the map. This will // trigger a call to panes_changed which should in turn call draw. this.setMap(opts.map); this.labelText = opts.labelText; this.icon = opts.icon; this.title = opts.title; this.kolor_ikony = opts.kolor_ikony||null; } window.LabeledMarker.prototype = new google.maps.OverlayView(); window.LabeledMarker.prototype.draw = function() { var me = this; // Check if the div has been created. var div = this.div_; if (!div) { // Create a overlay text DIV div = this.div_ = document.createElement('DIV'); // Create the DIV representing our LabeledMarker //div.style.border = "0px solid none"; div.style.position = "absolute"; div.style.paddingLeft = "0px"; div.style.cursor = 'pointer'; div.style.backgroundColor="white"; div.className="LabeledMarkerMainDiv"; this.divc = document.createElement("div"); this.img = document.createElement("img"); this.img.style.width='25px'; this.img.style.height='25px'; this.img.src = this.icon; this.divc.appendChild(this.img); this.divc.className="LabeledMarkerContentDiv"; div.appendChild(this.divc); this.span = document.createElement("span"); this.span.innerHTML=this.labelText; this.span.className = "LabeledMarker_markerLabel"; this.divc.appendChild(this.span); //z kolrkiem this.divlabelcolor = document.createElement("div"); if(this.kolor_ikony!=null) { this.divlabelcolor.style.backgroundColor=this.kolor_ikony; if(this.kolor_ikony=='black' || this.kolor_ikony=='blue' || this.kolor_ikony=='navy' || this.kolor_ikony=='maroon') { this.span.style.color='white'; } else { this.span.style.color='black'; } } this.divlabelcolor.className="LabeledMarkerKategoria"; div.appendChild(this.divlabelcolor); this.divlabelcolor=null; this.divc=null; this.span=null; this.img=null; google.maps.event.addDomListener(div, "click", function(event) { google.maps.event.trigger(me, "click"); }); google.maps.event.addDomListener(div, "mouseover", function(event) { google.maps.event.trigger(me, "mouseover"); }); google.maps.event.addDomListener(div, "mouseout", function(event) { google.maps.event.trigger(me, "mouseout"); }); // Then add the overlay to the DOM var panes = this.getPanes(); panes.overlayImage.appendChild(div); panes=null; } // Position the overlay //alert(typeof(this.latlng_.lng())); var point = this.getProjection().fromLatLngToDivPixel(this.latlng_); if (point) { var x= point.x-12; var y= point.y-12; div.style.left = x + 'px'; div.style.top = y + 'px'; } div=null; }; window.LabeledMarker.prototype.remove = function() { // Check if the overlay was on the map and needs to be removed. if (this.div_) { this.div_.parentNode.removeChild(this.div_); this.div_ = null; this.img=null; this.span=null; this.divlabelcolor=null; this.divc=null; this.labelText = null; this.icon = null; this.title = null; this.kolor_ikony = null; this.div_=null; } }; window.LabeledMarker.prototype.getPosition = function() { return this.latlng_; }; /*******************************koniec ladowania markerow wlasnych *******************/ GoogleInfoWindow = new google.maps.InfoWindow({pixelOffset: new google.maps.Size(5,0)}); LoadMap(); OtwartoMape=true; getLocationsAndMap(); } function showHidePanel(panel,button,txtPokaz,txtSchowaj) { // var key = panel.attr('id')+"_enableShow"; var key = "ant_schowaj_mape"; var show = false; if(panel.css("display")=="block") { panel.css("display","none"); button.html(txtPokaz); createCookie(key,"1",24*3600); show=true; } else { if(GoogleMap==null) { appendBootstrap(); } panel.css("display","block"); button.html(txtSchowaj); createCookie(key,"0",24*3600); } return show; } function initShowMap(panel,button,txtPokaz,txtSchowaj) { //var key = panel.attr('id')+"_enableShow"; var key = "ant_schowaj_mape"; var disableMap = readCookie(key); var show = false; if(disableMap!="1" ) { if(GoogleMap==null) { appendBootstrap(); } createCookie(key,"0",24*3600); panel.css("display","block"); button.html(txtSchowaj); show=true; } else { createCookie(key,"1",24*3600); panel.css("display","none"); button.html(txtPokaz); } return show; } function initShowMainMap(panel,button,txtPokaz,txtSchowaj,listapanel,link) { /*if(!initShowMap(panel,button,txtPokaz,txtSchowaj)) { listapanel.css("display","block"); listapanel.load(link,{},function() { }); } else {*/ listapanel.css("display","none"); if(GoogleMap==null) { appendBootstrap(); } //} } function showMainHidePanel(panel,button,txtPokaz,txtSchowaj,listapanel,link) { if(showHidePanel(panel,button,txtPokaz,txtSchowaj)) { listapanel.css("display","block"); listapanel.load(link,{},function() { }); } else { listapanel.css("display","none"); OdswiezObniektyNaMapie(); } } function addItemTujestemToScrollablePanel() { addItemToScrollablePanel(-1,"tujestem.gif",null,0); } function addItemToScrollablePanel(index,ikona,kolor,indexkategorii) { if(AntMapaScrollableLegend != null) { var item = $("
"); item.attr("class","legenda_item"); var html=""; if(index==-1) { html = "
Tutaj jesteś
"; } else { var kolorikony=""; if(kolor!=null) { kolorikony=kolor; } var kolorl = "black"; if(kolorikony=='black' || kolorikony=='blue' || kolorikony=='navy' || kolorikony=='maroon') { kolorl = "white"; } html = "
"+GoogleMarkers[index].title+"
"+indexkategorii+"
"; } item.html(html); item.click(function() { if(index==-1) { google.maps.event.trigger(markerTuJestem,'click'); } else { google.maps.event.trigger(GoogleMarkers[index],'click'); } }); AntMapaScrollableLegend.getItemWrap().append(item); item=null; html=null; } } function reloadScrollablePanel() { if(AntMapaScrollableLegend != null) { AntMapaScrollableLegend.reload().begin(); setPageScrollablePanel(); } } function setActiveItemScrollablePanel(index) { if(AntMapaScrollableLegend != null) { AntMapaScrollableLegend.click(index); } } function addScrollablePage(index,ikona,kolor,nazwa) { var pages = $('#mapa_legenda_pages'); var div = $("
"); var a = $(""); a.addClass('contentdiv'); //a.css('background-image','img/icons/mapa/tujestem.gif'); // var icon = GoogleMarkers[index].getIcon(); // alert(GoogleMarkers.length); var kolorl="black"; if(kolor=='black' || kolor=='blue' || kolor=='navy' || kolor=='maroon') { kolorl="white"; } a.html(""+nazwa+""); a.click(function() { var obj = $("#mapa_legenda"); $("#mapa_legenda_pages .active").removeClass('active'); $(this).addClass('active'); var count = AntMapaScrollableLegend.getItems().length-4; if(index>=count) { AntMapaScrollableLegend.end(); } else { AntMapaScrollableLegend.seekTo(index-1); } obj=null; }); div.append(a); pages.append(div); div=null; a=null; } function removeAllItemsFromScrollablePanel() { $("#mapa_legenda_pages div").remove(); if(AntMapaScrollableLegend != null) { AntMapaScrollableLegend.getItems().remove(); AntMapaScrollableLegend.reload().end(); } } function setPageScrollablePanel() { var s = 0; var obj = $("#mapa_legenda"); var c=0; if(AntMapaScrollableLegend != null) { c = AntMapaScrollableLegend.getIndex(); } else { return ; } var n = 0; $("#mapa_legenda_pages .active").removeClass('active'); for( var i in AntMapRodzaje) { if(i!=0) { s+=AntMapRodzaje[i]; if(s > c+1) { var count = AntMapaScrollableLegend.getItems().length-5; if(c>=count) { $("#mapa_legenda_pages a:last").addClass('active'); } else { $("#mapa_legenda_pages a").eq(n).addClass('active'); } c=null; obj=null; n=null; count=null; return; } n++; } } c=null; obj=null; n=null; } function removeItemToScrollablePanel() { if(AntMapaScrollableLegend != null) { AntMapaScrollableLegend.end(1); AntMapaScrollableLegend.getItems().filter(":last").remove(); AntMapaScrollableLegend.reload().prev(); } } function WyczyscMape() { var link = 'ajax.php?mapa,wyczyscmape,pol,,'; $("#formRodzaje :checkbox").each(function() { this.checked=false; }); $.get(link,function(data){getLocationsAndMap();}); } function WyczyscMapePotwierdz() { AntWindowManager.create('CzyszczenieMapyPotw', {width: 500, height: 250, title:'Wyczyść mapę...', content:'


Czy napewno chcesz wyczyścić mapę?', buttons: { 'Nie':function() { AntWindowManager.close('CzyszczenieMapyPotw'); }, 'Tak':function() { WyczyscMape(); AntWindowManager.close('CzyszczenieMapyPotw'); } } } ); } function AntMapaWybierzObiekty() { getLocationsAndMap(); AntWindowManager.close('MapaRodzajeWindow'); } function appendBootstrap() { var script = document.createElement("script"); script.type = "text/javascript"; /*script.onload = function() { //google.maps.loadScripts(); }; script.onreadystatechange= function () { if (this.readyState == 'loaded' || this.readyState == 'complete') { google.maps.loadScripts(); } };*/ script.src = "http://maps.google.com/maps/api/js?sensor=false&callback=handleApiReady"; document.body.appendChild(script); script=null; }