From 08b6349aa18e0de176ec61ec2c0015ab116a9588 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ses=C3=B3stris=20Vieira?= Date: Fri, 21 Dec 2012 11:22:04 -0200 Subject: [PATCH] =?UTF-8?q?Melhorias=20na=20interface=20do=20mapa=20de=20a?= =?UTF-8?q?tua=C3=A7=C3=A3o=20do=20Interlegis?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- media/js/metas/mapa.js | 18 ++++++++++++++---- sigi/templates/metas/mapa.html | 7 ++++++- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/media/js/metas/mapa.js b/media/js/metas/mapa.js index c3f9fee..5bbd38f 100644 --- a/media/js/metas/mapa.js +++ b/media/js/metas/mapa.js @@ -3,8 +3,9 @@ var municipiosArray = {}; $(document).ready(function($) { - $("input[type='checkbox']").change(filter); + $("input[type='checkbox']").change( filter ); $("#changelist-search").submit( search ); + $("#closeiwlink").click( closeAllInfowindows ); var latlng = new google.maps.LatLng(-14.2350040, -51.925280); var myOptions = { zoom: 5, @@ -40,7 +41,8 @@ var mark = new google.maps.Marker(markData); var infoWin = new google.maps.InfoWindow({content: '' + municipio.nome + '

' + municipio.info }); linkMarkMessage(mark, infoWin, map); - municipio['mapmark'] = mark + municipio['mapmark'] = mark; + municipio['infowindow'] = infoWin; municipiosArray[i] = municipio; } filter(null); @@ -52,6 +54,12 @@ google.maps.event.addListener(mark, 'click', function() {infoWin.open(map, mark);}); } + function closeAllInfowindows() { + for (var i in municipiosArray) { + municipiosArray[i]['infowindow'].close(); + } + } + function filter(event) { var data = $("#filter_form").serializeArray(); var estados = []; @@ -70,6 +78,7 @@ for (var i in municipiosArray) { var municipio = municipiosArray[i]; + municipio['infowindow'].close(); var aparece = false; if (regioes.indexOf(municipio.regiao) == -1 && estados.indexOf(municipio.estado) == -1) { @@ -99,7 +108,6 @@ } function search(event) { - var data = $.ajax({ url: "/sigi/dashboard/mapsearch/", type: 'GET', @@ -119,6 +127,9 @@ for (var i in return_data.ids) { var municipio = municipiosArray[return_data.ids[i]]; if (typeof(municipio) != 'undefined') { + if (municipio.mapmark.map == null) { + municipio.mapmark.setMap(map); + } google.maps.event.trigger(municipio.mapmark, 'click'); total = total + 1; } @@ -133,7 +144,6 @@ } else { $("#search-panel").html(total + ' municípios encontrados.'); } - }}); return false; } diff --git a/sigi/templates/metas/mapa.html b/sigi/templates/metas/mapa.html index 5cc2f60..d1e9f49 100644 --- a/sigi/templates/metas/mapa.html +++ b/sigi/templates/metas/mapa.html @@ -24,7 +24,12 @@   - + + {% endblock %}