Permalink
Browse files

updated js files properly after external contribution and bug report

  • Loading branch information...
1 parent 53c684e commit e907fe4d4edbad6705150e0f6f4ab5943cf4e593 @apneadiving apneadiving committed Jun 11, 2012
View
@@ -124,4 +124,4 @@ MIT license.
Authors: Benjamin Roth, David Ruyer
-Contributors: Mircea Pricop, Kamil Śliwak, Alex Vorobiev
+{Contributors} [https://github.com/apneadiving/Google-Maps-for-Rails/graphs/contributors]
@@ -363,47 +363,19 @@ class @Gmaps4Rails
@extendBoundsWithMarkers()
#from polylines:
- for polyline in @polylines
- polyline_points = polyline.serviceObject.latLngs.getArray()[0].getArray()
- for point in polyline_points
- @boundsObject.extend point
+ @updateBoundsWithPolylines()
#from polygons:
- for polygon in @polygons
- polygon_points = polygon.serviceObject.latLngs.getArray()[0].getArray()
- for point in polygon_points
- @boundsObject.extend point
+ @updateBoundsWithPolygons()
#from circles
- for circle in @circles
- @boundsObject.extend(circle.serviceObject.getBounds().getNorthEast())
- @boundsObject.extend(circle.serviceObject.getBounds().getSouthWest())
+ @updateBoundsWithCircles()
#in every case, I've to take into account the bounds set up by the user
- for bound in @map_options.bounds
- #create points from bounds provided
- #TODO:only works with google maps
- bound = @createLatLng(bound.lat, bound.lng)
- @boundsObject.extend bound
+ @extendMapBounds()
#SECOND_STEP: ajust the map to the bounds
-
- #if autozoom is false, take user info into account
- if !@map_options.auto_zoom
- map_center = @boundsObject.getCenter()
- @map_options.center_latitude = map_center.lat()
- @map_options.center_longitude = map_center.lng()
- @serviceObject.setCenter(map_center)
- else
- @fitBounds()
-
- #////////////////////////////////////////////////////
- #///////////////// KML //////////////////
- #////////////////////////////////////////////////////
-
- create_kml : ->
- for kml in @kml
- kml.serviceObject = @createKmlLayer kml
+ @adaptMapToBounds()
#////////////////////////////////////////////////////
#/////////////////// POLYLINES //////////////////////
@@ -161,3 +161,14 @@ class @Gmaps4RailsBing extends Gmaps4Rails
centerMapOnUser: ->
@serviceObject.setView({ center: @userLocation})
+
+ updateBoundsWithPolylines: ()->
+
+ updateBoundsWithPolygons: ()->
+
+ updateBoundsWithCircles: ()->
+
+ extendMapBounds :->
+
+ adaptMapToBounds: ->
+ @fitBounds()
@@ -287,7 +287,21 @@ class @Gmaps4RailsGoogle extends Gmaps4Rails
polyline.serviceObject = new_poly
new_poly.setMap(@serviceObject)
+
+ updateBoundsWithPolylines: ()->
+ for polyline in @polylines
+ polyline_points = polyline.serviceObject.latLngs.getArray()[0].getArray()
+ for point in polyline_points
+ @boundsObject.extend point
+
+ #////////////////////////////////////////////////////
+ #///////////////// KML //////////////////
+ #////////////////////////////////////////////////////
+ create_kml : ->
+ for kml in @kml
+ kml.serviceObject = @createKmlLayer kml
+
#////////////////////////////////////////////////////
#/////////////////// Other methods //////////////////
#////////////////////////////////////////////////////
@@ -297,4 +311,29 @@ class @Gmaps4RailsGoogle extends Gmaps4Rails
centerMapOnUser : ->
@serviceObject.setCenter(@userLocation)
-
+
+ updateBoundsWithPolygons: ()->
+ for polygon in @polygons
+ polygon_points = polygon.serviceObject.latLngs.getArray()[0].getArray()
+ for point in polygon_points
+ @boundsObject.extend point
+
+ updateBoundsWithCircles: ()->
+ for circle in @circles
+ @boundsObject.extend(circle.serviceObject.getBounds().getNorthEast())
+ @boundsObject.extend(circle.serviceObject.getBounds().getSouthWest())
+
+ extendMapBounds: ()->
+ for bound in @map_options.bounds
+ #create points from bounds provided
+ @boundsObject.extend @createLatLng(bound.lat, bound.lng)
+
+ adaptMapToBounds:()->
+ #if autozoom is false, take user info into account
+ if !@map_options.auto_zoom
+ map_center = @boundsObject.getCenter()
+ @map_options.center_latitude = map_center.lat()
+ @map_options.center_longitude = map_center.lng()
+ @serviceObject.setCenter(map_center)
+ else
+ @fitBounds()
@@ -131,4 +131,15 @@ class @Gmaps4RailsMapquest extends Gmaps4Rails
@serviceObject.addShape object
removeFromMap: (object)->
- @serviceObject.removeShape object
+ @serviceObject.removeShape object
+
+ updateBoundsWithPolylines: ()->
+
+ updateBoundsWithPolygons: ()->
+
+ updateBoundsWithCircles: ()->
+
+ extendMapBounds :->
+
+ adaptMapToBounds: ->
+ @fitBounds()
@@ -111,6 +111,7 @@ class @Gmaps4RailsOpenlayers extends Gmaps4Rails
@serviceObject.removeLayer(@markersLayer) if @markersLayer != null and @serviceObject.getLayer(@markersLayer.id) != null
extendBoundsWithMarkers: ->
+ console.log "here"
for marker in @markers
@boundsObject.extend(@createLatLng(marker.lat,marker.lng))
@@ -188,13 +189,13 @@ class @Gmaps4RailsOpenlayers extends Gmaps4Rails
null, true, @onPopupClose)
feature.popup = popup
popup.feature = feature
- @serviceObject.addPopup popup
+ @map.addPopup popup
onFeatureUnselect: (evt) ->
feature = evt.feature
if feature.popup
#//popup.feature = null;
- @serviceObject.removePopup feature.popup
+ @map.removePopup feature.popup
feature.popup.destroy()
feature.popup = null
@@ -236,8 +237,14 @@ class @Gmaps4RailsOpenlayers extends Gmaps4Rails
@polylinesLayer.addFeatures([polyline])
- return polyline
+ return polyline
+ updateBoundsWithPolylines: ()->
+
+ updateBoundsWithPolygons: ()->
+
+ updateBoundsWithCircles: ()->
+
# #////////////////////////////////////////////////////
# #/////////////////// Other methods //////////////////
# #////////////////////////////////////////////////////
@@ -248,3 +255,7 @@ class @Gmaps4RailsOpenlayers extends Gmaps4Rails
centerMapOnUser: ->
@serviceObject.setCenter @userLocation
+ extendMapBounds :->
+
+ adaptMapToBounds: ->
+ @fitBounds()

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit e907fe4

Please sign in to comment.