[Git][noosfero/noosfero][master] 2 commits: set max zoom google maps search

Gabriel Silva gitlab at mg.gitlab.com
Fri Apr 26 00:28:55 BRT 2019



Gabriel Silva pushed to branch master at Noosfero / noosfero


Commits:
1269205d by Nivaldo Neto at 2019-04-11T01:45:21Z
set max zoom google maps search

- - - - -
247ad519 by Gabriel Silva at 2019-04-26T03:28:53Z
Merge branch 'maps_max_zoom' into 'master'

set max zoom google maps search

See merge request noosfero/noosfero!1681
- - - - -


4 changed files:

- app/models/google_maps.rb
- app/views/search/_google_maps.html.erb
- config/noosfero.yml.dist
- public/javascripts/google_maps.js


Changes:

=====================================
app/models/google_maps.rb
=====================================
@@ -4,6 +4,10 @@ class GoogleMaps
     NOOSFERO_CONF['googlemaps_initial_zoom'] || 4
   end
 
+  def self.max_zoom
+    NOOSFERO_CONF['googlemaps_max_zoom'] || 15
+  end
+
   def self.js_api_key
     NOOSFERO_CONF['googlemaps_js_api_key']
   end


=====================================
app/views/search/_google_maps.html.erb
=====================================
@@ -16,6 +16,5 @@
       <% end %>
     <% end %>
   <% end %>
-
-  mapCenter();
+  mapCenter(null, <%= GoogleMaps.max_zoom.to_json %>);
 </script>


=====================================
config/noosfero.yml.dist
=====================================
@@ -7,6 +7,7 @@ development:
   addthis_options: favorites, email, digg, delicious, technorati, slashdot, twitter, more
   gravatar: mm
   googlemaps_initial_zoom: 15
+  googlemaps_max_zoom: 15
   googlemaps_js_api_key: your-js-key
   googlemaps_static_api_key: your-static-key
   exception_recipients: [admin at example.com]


=====================================
public/javascripts/google_maps.js
=====================================
@@ -54,7 +54,14 @@ function mapLoad(initialZoom, centerPoint) {
   });
 }
 
-function mapCenter(latlng) {
-  if (!latlng) map.fitBounds(mapBounds);
+function mapCenter(latlng, maxZoom) {
+  if (!latlng){
+    map.fitBounds(mapBounds);
+    google.maps.event.addListenerOnce(map, 'bounds_changed', function(event) {
+      // var maxZoom = 10;
+      if ( this.getZoom() > maxZoom)
+        this.setZoom(maxZoom);
+    });
+  }
   map.setCenter(latlng ? latlng : mapBounds.getCenter());
-}
+}
\ No newline at end of file



View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/78d0261022a1ca77739c18dde6c7df71fd724caa...247ad519f0d0361581dd1c435480fedb038b809d

-- 
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/78d0261022a1ca77739c18dde6c7df71fd724caa...247ad519f0d0361581dd1c435480fedb038b809d
You're receiving this email because of your account on gitlab.com.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20190426/3418806d/attachment-0001.html>


More information about the Noosfero-dev mailing list