następnie pobieram znaczniki będące tylko podzbiorem tamtych znaczników, czyszcząc oczywiście mapę i tablicę,
i jest ok do czasu kiedy zrobie zoom - powracają wszystkie poprzednie znaczniki.
Kod poucinany tu i ówdzie wygląda tak:
<script type='text/javascript'> <!-- var mapa = null; var obszar = null; var markery = []; var mmgr; $(function(){ load_map(); $("input[type=submit]").click(function(){ $('.ajax-loader').slideDown('slow'); var form = $("form#map_search").serialize(); $.ajax({ url: "<?php echo url::base(); ?>ajax/getObjects/", type: "POST", data: form, dataType: "xml", success: function(data){ markers = data.documentElement.getElementsByTagName('marker'); dodajMarkery(markers); $('.ajax-loader').slideUp('slow'); }, error: function( xhrInstance, message, optional ){ alert(xhrInstance + " - " + message); } }); return false; }); <?php if(isset($subdomain_city)){ ?> $("input[type=submit]").trigger('click'); <?php } ?> }); // definiuje ikony var icon_normal = new GIcon(); icon_normal.image = '<?php echo url::base(); ?>assets/img/marker_normal.png'; icon_normal.shadow = "<?php echo url::base(); ?>assets/img/shadow-marker_normal.png"; icon_normal.shadowSize = new GSize(25,16); icon_normal.iconSize = new GSize(16,16); icon_normal.infoWindowAnchor = new GPoint(16,16); icon_normal.iconAnchor = new GPoint(10,10); var icon_distinction = new GIcon(icon_normal); icon_distinction.image = '<?php echo url::base(); ?>assets/img/marker_distinction.png'; var icon_rebate = new GIcon(icon_normal); icon_rebate.image = '<?php echo url::base(); ?>assets/img/marker_rebate.png'; var icon_all_year = new GIcon(icon_normal); icon_all_year.image = '<?php echo url::base(); ?>assets/img/marker_all_year.png'; function dodajMarkery(markers) { wyczyscMape(); //console.log(markers); markers_number = markers.length; if(markers_number){ $("#lokalizator .details").show(); $("#lokalizator .details strong").html(markers_number); } else { $("#lokalizator .details").hide(); } for (var i = 0; i < markers_number; i++) { //console.log(i); _marker = markers[i]; var lat = _marker.getAttribute('lat'); var lng = _marker.getAttribute('lng'); var punktLatLng = new GLatLng(parseFloat(lat),parseFloat(lng)); icon = definiujIkone(_marker); var marker = new GMarker(punktLatLng, {icon: icon, clickable: true, title: _marker.getAttribute('title')}); dodajMarker(marker, minimalnyZoom(_marker), "<div style='width: 300px; overflow: hidden;'><div style='float: left; width: 18px;'><img src='"+icon.image+"' /></div><div style='float: left; width: 280px;'><a href='<?php echo url::base(); ?>"+_marker.getAttribute('category_slug')+","+_marker.getAttribute('id')+"' style='font-size: 1.1em;'><strong>"+_marker.getAttribute('title')+"</strong></a><br /><div style='padding: 10px 0; margin-top: 10px; border-bottom: 1px solid #eee; border-top: 1px solid #eee;'>"+_marker.getAttribute('description')+"</div><br /><a href='<?php echo url::base(); ?>"+_marker.getAttribute('category_slug')+","+_marker.getAttribute('id')+"'><img src='"+_marker.getAttribute('image')+"' style='border: 1px solid #f3f3f3; width: 100px; margin: 10px 0 0 75px;' /></a></div></div>"); markery.push(marker); } } function dodajMarker(marker, minZoom, html){ mmgr.addMarker(marker, minZoom, 17); GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(html); }); } function definiujIkone(marker){ if(marker.getAttribute('distinction') == 1) icon_type = icon_distinction; else if(marker.getAttribute('rebate') != 0) icon_type = icon_rebate; else if(marker.getAttribute('all_year') == 1) icon_type = icon_all_year; else icon_type = icon_normal; return icon_type; } function wyczyscMape(){ mapa.clearOverlays(); var markery = []; } function minimalnyZoom(marker_xml){ packet = marker_xml.getAttribute('packet'); if(packet == 2) return 11; else if(packet == 1) return 9; else if(packet == 3) return 7; } function load_map() { if(GBrowserIsCompatible()) { mapa = new google.maps.Map(document.getElementById('map')); mmgr = new GMarkerManager(mapa,{maxZoom: 17}); <?php if(isset($subdomain_city)){ ?> mapa.setCenter(new GLatLng(<?php echo $subdomain_city->lat ?>,<?php echo $subdomain_city->lng ?>),14); <?php } else { ?> mapa.setCenter(new GLatLng(53.90692700949985,17.830810546875),7); <?php } ?> mapa.addControl(new GScaleControl()); mapa.addControl(new GLargeMapControl()); mapa.addControl(new GMapTypeControl()); mapa.enableContinuousZoom(); mapa.enableScrollWheelZoom(); mapa.addControl(new GOverviewMapControl()); mapa.addMapType(G_PHYSICAL_MAP) GEvent.addListener(mapa,'mousemove',function(p) { if(!obszar || !obszar.punkt1) return; obszar.ustawPunktKoncowy(p); }); GEvent.addListener(mapa,'click',function(o,p) { if(obszar && obszar.status != "stop"){ obszar.remove(); obszar = null; } }); GEvent.addListener(mapa,'singlerightclick',function(o,p) { //if(!p) return; if(obszar && obszar.status == "stop"){ obszar.remove(); obszar = null; } if(!obszar){ p = mapa.fromContainerPixelToLatLng(o); obszar = new ZaznaczObszar(p); obszar.status = "move"; mapa.addOverlay(obszar); } else { obszar.status = "stop"; latlngs = obszar.pobierz(); window.location = "<?php echo url::base(); ?>szukaj?latlngs="+latlngs; } }); } } --> </script>