Commit 7311bf8493798604438661ed513db09a9120d1d7
1 parent
f28846f9
Exists in
master
and in
8 other branches
ActionItem525: zoom to searched enterprises in google map
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@2122 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
1 changed file
with
7 additions
and
2 deletions
Show diff stats
app/views/search/_google_maps.rhtml
... | ... | @@ -10,7 +10,6 @@ |
10 | 10 | var points = {}; |
11 | 11 | |
12 | 12 | function putMarker(lat, lng, title, summary) { |
13 | - | |
14 | 13 | var point_str = lat + ":" + lng; |
15 | 14 | |
16 | 15 | if (points[point_str]) { |
... | ... | @@ -21,13 +20,13 @@ function putMarker(lat, lng, title, summary) { |
21 | 20 | } |
22 | 21 | |
23 | 22 | var point = new GLatLng(lat, lng); |
24 | - | |
25 | 23 | var options = { 'title' : title }; |
26 | 24 | var marker = new GMarker(point, options); |
27 | 25 | map.addOverlay(marker); |
28 | 26 | GEvent.addListener(marker, 'click', function() { |
29 | 27 | map.openInfoWindowHtml(point, summary); |
30 | 28 | }); |
29 | + bounds.extend(point); | |
31 | 30 | } |
32 | 31 | |
33 | 32 | window.unload = function() { |
... | ... | @@ -43,12 +42,15 @@ if (GBrowserIsCompatible()) { |
43 | 42 | |
44 | 43 | centerPoint = new GLatLng(-15.0, -50.1419); |
45 | 44 | map.setCenter(centerPoint, <%= GoogleMaps.initial_zoom.to_json %>); |
45 | + var bounds = new GLatLngBounds(); | |
46 | + | |
46 | 47 | <% |
47 | 48 | missed = false |
48 | 49 | @results.each do |name,results| |
49 | 50 | results.each do |item| |
50 | 51 | if item.lat && item.lng |
51 | 52 | %> |
53 | + | |
52 | 54 | putMarker(<%= item.lat.to_json %>, <%= item.lng.to_json %>, <%= item.name.to_json %>, <%= display_profile_info(item).to_json %>); |
53 | 55 | <% |
54 | 56 | else |
... | ... | @@ -61,4 +63,7 @@ if (GBrowserIsCompatible()) { |
61 | 63 | <%= "map.openInfoWindowHtml(centerPoint, %s);" % _("One or more items don't have geographical information, and won't be shown in the map. Choose \"Display in list\" to see them.").to_json %> |
62 | 64 | <% end %> |
63 | 65 | } |
66 | + | |
67 | + map.setZoom(map.getBoundsZoomLevel(bounds)); | |
68 | + map.setCenter(bounds.getCenter()); | |
64 | 69 | </script> | ... | ... |