gmaps4rails 2.0.0.pre → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +2 -4
- data/Gemfile +5 -1
- data/Gemfile.lock +31 -113
- data/README.rdoc +53 -70
- data/Rakefile +21 -1
- data/gmaps4rails.gemspec +4 -19
- data/js_compilation/gmaps_google.js +961 -0
- data/lib/generators/gmaps4rails/copy_coffee_generator.rb +14 -0
- data/lib/generators/gmaps4rails/copy_js_generator.rb +15 -0
- data/lib/gmaps4rails.rb +12 -22
- data/lib/gmaps4rails/markers_builder.rb +74 -0
- data/lib/gmaps4rails/rails/engine.rb +6 -0
- data/lib/gmaps4rails/rails/railtie.rb +6 -0
- data/lib/gmaps4rails/version.rb +2 -2
- data/script/compile_coffee_files.rb +19 -0
- data/script/gmaps4rails.rake +7 -0
- data/spec/javascripts/google/builders/marker_spec.js +96 -0
- data/spec/javascripts/helpers/SpecHelper.js +101 -0
- data/spec/javascripts/helpers/matchers.js +12 -0
- data/spec/javascripts/helpers/underscore.js +6 -0
- data/spec/javascripts/objects/handler_spec.js +320 -0
- data/spec/javascripts/support/jasmine.yml +86 -0
- data/spec/javascripts/support/jasmine_helper.rb +11 -0
- data/spec/lib/base_spec.rb +10 -52
- data/spec/lib/markers_builder_spec.rb +49 -0
- data/spec/spec_helper.rb +1 -25
- data/vendor/assets/javascripts/gmaps/base.coffee +16 -0
- data/vendor/assets/javascripts/gmaps/base/base.coffee +17 -0
- data/vendor/assets/javascripts/gmaps/google.coffee +3 -0
- data/vendor/assets/javascripts/gmaps/google/builders/bound.coffee +6 -0
- data/vendor/assets/javascripts/gmaps/google/builders/circle.coffee +21 -0
- data/vendor/assets/javascripts/gmaps/google/builders/clusterer.coffee +6 -0
- data/vendor/assets/javascripts/gmaps/google/builders/kml.coffee +17 -0
- data/vendor/assets/javascripts/gmaps/google/builders/map.coffee +27 -0
- data/vendor/assets/javascripts/gmaps/google/builders/marker.coffee +100 -0
- data/vendor/assets/javascripts/gmaps/google/builders/polygon.coffee +24 -0
- data/vendor/assets/javascripts/gmaps/google/builders/polyline.coffee +24 -0
- data/vendor/assets/javascripts/gmaps/google/objects/bound.coffee +13 -0
- data/vendor/assets/javascripts/gmaps/google/objects/circle.coffee +9 -0
- data/vendor/assets/javascripts/gmaps/google/objects/clusterer.coffee +13 -0
- data/vendor/assets/javascripts/gmaps/google/objects/common.coffee +23 -0
- data/vendor/assets/javascripts/gmaps/google/objects/kml.coffee +15 -0
- data/vendor/assets/javascripts/gmaps/google/objects/map.coffee +19 -0
- data/vendor/assets/javascripts/gmaps/google/objects/marker.coffee +11 -0
- data/vendor/assets/javascripts/gmaps/google/objects/polygon.coffee +8 -0
- data/vendor/assets/javascripts/gmaps/google/objects/polyline.coffee +8 -0
- data/vendor/assets/javascripts/gmaps/google/primitives.coffee +43 -0
- data/vendor/assets/javascripts/gmaps/objects/base_builder.coffee +20 -0
- data/vendor/assets/javascripts/gmaps/objects/builder.coffee +12 -0
- data/vendor/assets/javascripts/gmaps/objects/handler.coffee +153 -0
- data/vendor/assets/javascripts/gmaps/objects/null_clusterer.coffee +4 -0
- metadata +66 -299
- data/Guardfile.old +0 -24
- data/app/views/gmaps4rails/_gmaps4rails.html.erb +0 -20
- data/lib/generators/gmaps4rails/install_generator.rb +0 -43
- data/lib/generators/templates/README +0 -2
- data/lib/gmaps4rails/acts_as_gmappable.rb +0 -54
- data/lib/gmaps4rails/api_wrappers/base_net_methods.rb +0 -40
- data/lib/gmaps4rails/api_wrappers/direction.rb +0 -87
- data/lib/gmaps4rails/api_wrappers/geocoder.rb +0 -54
- data/lib/gmaps4rails/api_wrappers/places.rb +0 -74
- data/lib/gmaps4rails/base.rb +0 -126
- data/lib/gmaps4rails/extensions/enumerable.rb +0 -14
- data/lib/gmaps4rails/extensions/hash.rb +0 -9
- data/lib/gmaps4rails/helper/gmaps4rails_helper.rb +0 -33
- data/lib/gmaps4rails/js_builder.rb +0 -154
- data/lib/gmaps4rails/json_builder.rb +0 -140
- data/lib/gmaps4rails/model_handler.rb +0 -101
- data/lib/gmaps4rails/view_helper.rb +0 -172
- data/lib/tasks/jasmine.rake +0 -8
- data/public/javascripts/gmaps4rails/all.js +0 -2144
- data/public/javascripts/gmaps4rails/base.js +0 -792
- data/public/javascripts/gmaps4rails/google.js +0 -556
- data/public/javascripts/gmaps4rails/openlayers.js +0 -377
- data/public/stylesheets/gmaps4rails.css +0 -24
- data/spec/dummy/.gitignore +0 -3
- data/spec/dummy/.rspec +0 -1
- data/spec/dummy/README.rdoc +0 -261
- data/spec/dummy/Rakefile +0 -7
- data/spec/dummy/app/assets/javascripts/application.js +0 -18
- data/spec/dummy/app/assets/stylesheets/application.css +0 -15
- data/spec/dummy/app/assets/stylesheets/gmaps4rails.css +0 -24
- data/spec/dummy/app/controllers/application_controller.rb +0 -3
- data/spec/dummy/app/controllers/users_controller.rb +0 -105
- data/spec/dummy/app/helpers/application_helper.rb +0 -2
- data/spec/dummy/app/mailers/.gitkeep +0 -0
- data/spec/dummy/app/models/.gitkeep +0 -0
- data/spec/dummy/app/models/place.rb +0 -16
- data/spec/dummy/app/models/user.rb +0 -12
- data/spec/dummy/app/views/layouts/application.html.erb +0 -17
- data/spec/dummy/app/views/users/_form.html.erb +0 -37
- data/spec/dummy/app/views/users/edit.html.erb +0 -6
- data/spec/dummy/app/views/users/index.html.erb +0 -268
- data/spec/dummy/app/views/users/new.html.erb +0 -5
- data/spec/dummy/app/views/users/show.html.erb +0 -30
- data/spec/dummy/config.ru +0 -4
- data/spec/dummy/config/application.rb +0 -62
- data/spec/dummy/config/boot.rb +0 -10
- data/spec/dummy/config/database.yml +0 -25
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/development.rb +0 -37
- data/spec/dummy/config/environments/production.rb +0 -67
- data/spec/dummy/config/environments/test.rb +0 -37
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy/config/initializers/gmaps4rails.rb +0 -1
- data/spec/dummy/config/initializers/inflections.rb +0 -15
- data/spec/dummy/config/initializers/mime_types.rb +0 -5
- data/spec/dummy/config/initializers/secret_token.rb +0 -7
- data/spec/dummy/config/initializers/session_store.rb +0 -8
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/spec/dummy/config/locales/en.yml +0 -5
- data/spec/dummy/config/routes.rb +0 -60
- data/spec/dummy/db/migrate/20120408170155_create_users.rb +0 -16
- data/spec/dummy/db/schema.rb +0 -29
- data/spec/dummy/lib/assets/.gitkeep +0 -0
- data/spec/dummy/log/.gitkeep +0 -0
- data/spec/dummy/public/404.html +0 -26
- data/spec/dummy/public/422.html +0 -26
- data/spec/dummy/public/500.html +0 -25
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/javascripts/Player.js +0 -22
- data/spec/dummy/public/javascripts/Song.js +0 -7
- data/spec/dummy/public/logo.png +0 -0
- data/spec/dummy/script/rails +0 -6
- data/spec/factories/place_factory.rb +0 -16
- data/spec/factories/user_factory.rb +0 -23
- data/spec/fixtures/google_direction_valid.json +0 -65
- data/spec/fixtures/google_geocoding_toulon_france.json +0 -58
- data/spec/fixtures/google_places_valid.json +0 -45
- data/spec/fixtures/google_wrong_geocoding.json +0 -4
- data/spec/launchers/all_but_requests.rb +0 -0
- data/spec/launchers/all_specs.rb +0 -0
- data/spec/launchers/requests.rb +0 -0
- data/spec/lib/direction_spec.rb +0 -53
- data/spec/lib/geocoder_spec.rb +0 -46
- data/spec/lib/js_builder_spec.rb +0 -134
- data/spec/lib/json_builder_spec.rb +0 -232
- data/spec/lib/places_spec.rb +0 -25
- data/spec/models/place_spec.rb +0 -39
- data/spec/models/user_spec.rb +0 -187
- data/spec/support/geocoding.rb +0 -40
- data/spec/support/matchers.rb +0 -73
- data/todo +0 -0
- data/vendor/assets/javascripts/gmaps4rails/all.js +0 -1
- data/vendor/assets/javascripts/gmaps4rails/base.coffee +0 -1
- data/vendor/assets/javascripts/gmaps4rails/base/common.coffee +0 -43
- data/vendor/assets/javascripts/gmaps4rails/base/configuration.coffee +0 -7
- data/vendor/assets/javascripts/gmaps4rails/base/gmaps.coffee +0 -13
- data/vendor/assets/javascripts/gmaps4rails/base/interfaces/basic_interface.coffee +0 -15
- data/vendor/assets/javascripts/gmaps4rails/base/interfaces/controller_interface.coffee +0 -15
- data/vendor/assets/javascripts/gmaps4rails/base/interfaces/map_interface.coffee +0 -27
- data/vendor/assets/javascripts/gmaps4rails/base/interfaces/marker_interface.coffee +0 -15
- data/vendor/assets/javascripts/gmaps4rails/base/main.coffee +0 -124
- data/vendor/assets/javascripts/gmaps4rails/base/main_controller_extensions/circle_controller.coffee +0 -29
- data/vendor/assets/javascripts/gmaps4rails/base/main_controller_extensions/kml_controller.coffee +0 -5
- data/vendor/assets/javascripts/gmaps4rails/base/main_controller_extensions/marker_controller.coffee +0 -76
- data/vendor/assets/javascripts/gmaps4rails/base/main_controller_extensions/polygon_controller.coffee +0 -29
- data/vendor/assets/javascripts/gmaps4rails/base/main_controller_extensions/polyline_controller.coffee +0 -29
- data/vendor/assets/javascripts/gmaps4rails/base/objects/circle.coffee +0 -12
- data/vendor/assets/javascripts/gmaps4rails/base/objects/kml.coffee +0 -8
- data/vendor/assets/javascripts/gmaps4rails/base/objects/map.coffee +0 -62
- data/vendor/assets/javascripts/gmaps4rails/base/objects/marker.coffee +0 -24
- data/vendor/assets/javascripts/gmaps4rails/base/objects/polygon.coffee +0 -11
- data/vendor/assets/javascripts/gmaps4rails/base/objects/polyline.coffee +0 -11
- data/vendor/assets/javascripts/gmaps4rails/bing.coffee +0 -1
- data/vendor/assets/javascripts/gmaps4rails/bing/main.coffee +0 -29
- data/vendor/assets/javascripts/gmaps4rails/bing/objects/map.coffee +0 -63
- data/vendor/assets/javascripts/gmaps4rails/bing/objects/marker.coffee +0 -78
- data/vendor/assets/javascripts/gmaps4rails/bing/shared.coffee +0 -20
- data/vendor/assets/javascripts/gmaps4rails/google.coffee +0 -1
- data/vendor/assets/javascripts/gmaps4rails/google/main.coffee +0 -47
- data/vendor/assets/javascripts/gmaps4rails/google/objects/circle.coffee +0 -38
- data/vendor/assets/javascripts/gmaps4rails/google/objects/kml.coffee +0 -16
- data/vendor/assets/javascripts/gmaps4rails/google/objects/map.coffee +0 -71
- data/vendor/assets/javascripts/gmaps4rails/google/objects/marker.coffee +0 -114
- data/vendor/assets/javascripts/gmaps4rails/google/objects/polygon.coffee +0 -38
- data/vendor/assets/javascripts/gmaps4rails/google/objects/polyline.coffee +0 -49
- data/vendor/assets/javascripts/gmaps4rails/google/shared.coffee +0 -27
- data/vendor/assets/javascripts/gmaps4rails/openlayers.coffee +0 -1
- data/vendor/assets/javascripts/gmaps4rails/openlayers/main.coffee +0 -138
- data/vendor/assets/javascripts/gmaps4rails/openlayers/objects/map.coffee +0 -49
- data/vendor/assets/javascripts/gmaps4rails/openlayers/objects/marker.coffee +0 -68
- data/vendor/assets/javascripts/gmaps4rails/openlayers/objects/polyline.coffee +0 -39
- data/vendor/assets/javascripts/gmaps4rails/openlayers/shared.coffee +0 -19
@@ -1,124 +0,0 @@
|
|
1
|
-
#= require './common'
|
2
|
-
#= require './configuration'
|
3
|
-
#= require './gmaps'
|
4
|
-
|
5
|
-
#= require_tree './objects'
|
6
|
-
#= require_tree './main_controller_extensions'
|
7
|
-
#= require_tree './interfaces'
|
8
|
-
|
9
|
-
class @Gmaps4Rails.BaseController extends Gmaps4Rails.Common
|
10
|
-
|
11
|
-
@include Gmaps4Rails.MarkerController
|
12
|
-
@include Gmaps4Rails.PolylineController
|
13
|
-
@include Gmaps4Rails.PolygonController
|
14
|
-
@include Gmaps4Rails.CircleController
|
15
|
-
@include Gmaps4Rails.KmlController
|
16
|
-
|
17
|
-
@include Gmaps4Rails.Interfaces.Controller
|
18
|
-
|
19
|
-
visibleInfoWindow: null #contains the current opened infowindow
|
20
|
-
userLocation: null #contains user's location if geolocalization was performed and successful
|
21
|
-
|
22
|
-
#empty slots
|
23
|
-
afterMapInitialization: -> false
|
24
|
-
geolocationSuccess: -> false
|
25
|
-
geolocationFailure: -> false #triggered when geolocation fails. If customized, must be like= function(navigator_handles_geolocation){} where 'navigator_handles_geolocation' is a boolean
|
26
|
-
callback: -> false #to let user set a custom callback function
|
27
|
-
customClusterer: -> false #to let user set custom clusterer pictures
|
28
|
-
infobox: -> false #to let user use custom infoboxes
|
29
|
-
jsTemplate: false #to let user create infowindows client side
|
30
|
-
|
31
|
-
|
32
|
-
#Stored variables
|
33
|
-
map_options: {} # deleted once map is created
|
34
|
-
markers: [] # contains all markers. A marker contains the following: {"description": , "longitude": , "title":, "latitude":, "picture": "", "width": "", "length": "", "sidebar": "", "serviceObject": google_marker}
|
35
|
-
boundsObject: null # contains current bounds from markers, polylines etc...
|
36
|
-
polygons: [] # contains raw data, array of arrays (first element could be a hash containing options)
|
37
|
-
polylines: [] # contains raw data, array of arrays (first element could be a hash containing options)
|
38
|
-
circles: [] # contains raw data, array of hash
|
39
|
-
markerClusterer: null # contains all marker clusterers
|
40
|
-
markerImages: []
|
41
|
-
kmls: []
|
42
|
-
rootModule: null
|
43
|
-
|
44
|
-
constructor: ->
|
45
|
-
@rootModule = @getModule()
|
46
|
-
@markers_conf = @rootModule.Marker.setConf() if @rootModule.Marker?
|
47
|
-
@polylines_conf = @rootModule.Polyline.setConf() if @rootModule.Polyline?
|
48
|
-
@polygons_conf = @rootModule.Polygon.setConf() if @rootModule.Polygon?
|
49
|
-
@circles_conf = @rootModule.Circle.setConf() if @rootModule.Circle?
|
50
|
-
|
51
|
-
#////////////////////////////////////////////////////
|
52
|
-
#/////////////// Basic Objects //////////////
|
53
|
-
#////////////////////////////////////////////////////
|
54
|
-
|
55
|
-
createMap : ->
|
56
|
-
new @rootModule.Map(@map_options, @)
|
57
|
-
|
58
|
-
createMarker: (args)->
|
59
|
-
new @rootModule.Marker(args, @)
|
60
|
-
|
61
|
-
createPolyline: (args)->
|
62
|
-
new @rootModule.Polyline(args, @)
|
63
|
-
|
64
|
-
createPolygon: (args)->
|
65
|
-
new @rootModule.Polygon(args, @)
|
66
|
-
|
67
|
-
createCircle: (args)->
|
68
|
-
new @rootModule.Circle(args, @)
|
69
|
-
|
70
|
-
createKml: (args)->
|
71
|
-
new @rootModule.Kml(args, @)
|
72
|
-
|
73
|
-
#///////////////////////////////////
|
74
|
-
#/////////////// Map //////////////
|
75
|
-
#///////////////////////////////////
|
76
|
-
|
77
|
-
initialize : ->
|
78
|
-
detectUserLocation = @map_options.detect_location or @map_options.center_on_user
|
79
|
-
center_on_user = @map_options.center_on_user
|
80
|
-
@map = @createMap()
|
81
|
-
@afterMapInitialization()
|
82
|
-
|
83
|
-
delete @map_options
|
84
|
-
|
85
|
-
if detectUserLocation
|
86
|
-
@findUserLocation(this, center_on_user)
|
87
|
-
|
88
|
-
getMapObject: ->
|
89
|
-
@map.serviceObject
|
90
|
-
|
91
|
-
adjustMapToBounds: ->
|
92
|
-
@map.adjustToBounds() if @map.autoAdjustRequested()
|
93
|
-
|
94
|
-
#////////////////////////////////////////////////////
|
95
|
-
#/////////////// Miscellaneous //////////////
|
96
|
-
#////////////////////////////////////////////////////
|
97
|
-
|
98
|
-
clusterize : ->
|
99
|
-
if @markers_conf.do_clustering
|
100
|
-
#first clear the existing clusterer if any
|
101
|
-
@clearClusterer() if @markerClusterer?
|
102
|
-
|
103
|
-
markers_array = []
|
104
|
-
for marker in @markers
|
105
|
-
markers_array.push(marker.serviceObject)
|
106
|
-
|
107
|
-
@markerClusterer = @createClusterer(markers_array)
|
108
|
-
|
109
|
-
findUserLocation : (controller, center_on_user) ->
|
110
|
-
if navigator.geolocation
|
111
|
-
#try to retrieve user's position
|
112
|
-
positionSuccessful = (position) ->
|
113
|
-
controller.userLocation = controller.createLatLng(position.coords.latitude, position.coords.longitude)
|
114
|
-
#change map's center to focus on user's geoloc if asked
|
115
|
-
controller.geolocationSuccess()
|
116
|
-
if center_on_user
|
117
|
-
controller.map.centerMapOnUser(controller.userLocation)
|
118
|
-
positionFailure = (error)->
|
119
|
-
controller.geolocationFailure(true)
|
120
|
-
|
121
|
-
navigator.geolocation.getCurrentPosition( positionSuccessful, positionFailure)
|
122
|
-
else
|
123
|
-
#failure but the navigator doesn't handle geolocation
|
124
|
-
controller.geolocationFailure(false)
|
data/vendor/assets/javascripts/gmaps4rails/base/main_controller_extensions/circle_controller.coffee
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
@Gmaps4Rails.CircleController =
|
2
|
-
|
3
|
-
#polygons is an array of arrays. It loops.
|
4
|
-
addCircles: (circleData)->
|
5
|
-
for circleArgs in circleData
|
6
|
-
@circles.push @createCircle(circleArgs)
|
7
|
-
|
8
|
-
replaceCircles : (circleData) ->
|
9
|
-
#reset previous polylines and kill them from map
|
10
|
-
@clearCircles()
|
11
|
-
#set new polylines
|
12
|
-
@addCircles(circleData)
|
13
|
-
#.... and adjust map boundaries
|
14
|
-
@adjustMapToBounds()
|
15
|
-
|
16
|
-
clearCircles : ->
|
17
|
-
for circle in @circles
|
18
|
-
#delete polylines from map
|
19
|
-
circle.clear()
|
20
|
-
#empty array
|
21
|
-
@circles = []
|
22
|
-
|
23
|
-
showCircles : ->
|
24
|
-
for circle in @circles
|
25
|
-
circle.show()
|
26
|
-
|
27
|
-
hideCircles : ->
|
28
|
-
for circle in @circles
|
29
|
-
circle.hide()
|
data/vendor/assets/javascripts/gmaps4rails/base/main_controller_extensions/marker_controller.coffee
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
@Gmaps4Rails.MarkerController =
|
2
|
-
|
3
|
-
addMarkers: (markersData)->
|
4
|
-
@clearClusterer() if @markerClusterer?
|
5
|
-
|
6
|
-
for markerData, index in markersData
|
7
|
-
#unless markerData.serviceObject?
|
8
|
-
|
9
|
-
lat = markerData.lat
|
10
|
-
lng = markerData.lng
|
11
|
-
|
12
|
-
if @markers_conf.randomize
|
13
|
-
latLng = @randomize(lat, lng)
|
14
|
-
#retrieve coordinates from the array
|
15
|
-
lat = latLng[0]
|
16
|
-
lng = latLng[1]
|
17
|
-
|
18
|
-
newMarker = @createMarker
|
19
|
-
"marker_picture": if markerData.picture then markerData.picture else @markers_conf.picture
|
20
|
-
"marker_width": if markerData.width then markerData.width else @markers_conf.width
|
21
|
-
"marker_height": if markerData.height then markerData.height else @markers_conf.length
|
22
|
-
"marker_title": if markerData.title then markerData.title else null
|
23
|
-
"marker_anchor": if markerData.marker_anchor then markerData.marker_anchor else null
|
24
|
-
"shadow_anchor": if markerData.shadow_anchor then markerData.shadow_anchor else null
|
25
|
-
"shadow_picture": if markerData.shadow_picture then markerData.shadow_picture else null
|
26
|
-
"shadow_width": if markerData.shadow_width then markerData.shadow_width else null
|
27
|
-
"shadow_height": if markerData.shadow_height then markerData.shadow_height else null
|
28
|
-
"marker_draggable": if markerData.draggable then markerData.draggable else @markers_conf.draggable
|
29
|
-
"rich_marker": if markerData.rich_marker then markerData.rich_marker else null
|
30
|
-
"zindex": if markerData.zindex then markerData.zindex else null
|
31
|
-
"lat": lat
|
32
|
-
"lng": lng
|
33
|
-
"index": index
|
34
|
-
|
35
|
-
|
36
|
-
Gmaps4Rails.Common.mergeWith.call(newMarker, markerData)
|
37
|
-
#add infowindowstuff if enabled
|
38
|
-
newMarker.createInfoWindow()
|
39
|
-
|
40
|
-
@markers.push newMarker
|
41
|
-
|
42
|
-
@clusterize()
|
43
|
-
|
44
|
-
#replace old markers with new markers on an existing map
|
45
|
-
replaceMarkers : (new_markers) ->
|
46
|
-
@clearMarkers()
|
47
|
-
#reset previous markers
|
48
|
-
@markers = []
|
49
|
-
#reset current bounds
|
50
|
-
@boundsObject = @createLatLngBounds()
|
51
|
-
#add new markers
|
52
|
-
@addMarkers(new_markers)
|
53
|
-
|
54
|
-
#clear markers
|
55
|
-
clearMarkers : ->
|
56
|
-
@clearClusterer() if @markerClusterer?
|
57
|
-
for marker in @markers
|
58
|
-
marker.clear()
|
59
|
-
@markers = []
|
60
|
-
|
61
|
-
#show and hide markers
|
62
|
-
showMarkers : ->
|
63
|
-
for marker in @markers
|
64
|
-
marker.show()
|
65
|
-
|
66
|
-
hideMarkers : ->
|
67
|
-
for marker in @markers
|
68
|
-
marker.hide()
|
69
|
-
|
70
|
-
randomize : (Lat0, Lng0) ->
|
71
|
-
#distance in meters between 0 and max_random_distance (positive or negative)
|
72
|
-
dx = @markers_conf.max_random_distance * @random()
|
73
|
-
dy = @markers_conf.max_random_distance * @random()
|
74
|
-
Lat = parseFloat(Lat0) + (180/Math.PI)*(dy/6378137)
|
75
|
-
Lng = parseFloat(Lng0) + ( 90/Math.PI)*(dx/6378137)/Math.cos(Lat0)
|
76
|
-
return [Lat, Lng]
|
data/vendor/assets/javascripts/gmaps4rails/base/main_controller_extensions/polygon_controller.coffee
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
@Gmaps4Rails.PolygonController =
|
2
|
-
|
3
|
-
#polygons is an array of arrays. It loops.
|
4
|
-
addPolygons: (polygonData)->
|
5
|
-
for polygonArgs in polygonData
|
6
|
-
@polygons.push @createPolygon(polygonArgs)
|
7
|
-
|
8
|
-
replacePolygons : (polylineData) ->
|
9
|
-
#reset previous polylines and kill them from map
|
10
|
-
@clearPolygons()
|
11
|
-
#set new polylines
|
12
|
-
@addPolygons(polylineData)
|
13
|
-
#.... and adjust map boundaries
|
14
|
-
@adjustMapToBounds()
|
15
|
-
|
16
|
-
clearPolygons : ->
|
17
|
-
for polygon in @polygons
|
18
|
-
#delete polylines from map
|
19
|
-
polygon.clear()
|
20
|
-
#empty array
|
21
|
-
@polygons = []
|
22
|
-
|
23
|
-
showPolygons : ->
|
24
|
-
for polygon in @polygons
|
25
|
-
polygon.show()
|
26
|
-
|
27
|
-
hidePolygons : ->
|
28
|
-
for polygon in @polygons
|
29
|
-
polygon.hide()
|
@@ -1,29 +0,0 @@
|
|
1
|
-
@Gmaps4Rails.PolylineController =
|
2
|
-
|
3
|
-
replacePolylines : (polylineData) ->
|
4
|
-
#reset previous polylines and kill them from map
|
5
|
-
@clearPolylines()
|
6
|
-
#set new polylines
|
7
|
-
@addPolylines(polylineData)
|
8
|
-
#.... and adjust map boundaries
|
9
|
-
@adjustMapToBounds()
|
10
|
-
|
11
|
-
clearPolylines : ->
|
12
|
-
for polyline in @polylines
|
13
|
-
#delete polylines from map
|
14
|
-
polyline.clear()
|
15
|
-
#empty array
|
16
|
-
@polylines = []
|
17
|
-
|
18
|
-
#polylines is an array of arrays. It loops.
|
19
|
-
addPolylines: (polylineData)->
|
20
|
-
for polylineArgs in polylineData
|
21
|
-
@polylines.push @createPolyline(polylineArgs)
|
22
|
-
|
23
|
-
showPolylines : ->
|
24
|
-
for polyline in @polylines
|
25
|
-
polyline.show()
|
26
|
-
|
27
|
-
hidePolylines : ->
|
28
|
-
for polyline in @polylines
|
29
|
-
polyline.hide()
|
@@ -1,62 +0,0 @@
|
|
1
|
-
@Gmaps4Rails.Map =
|
2
|
-
|
3
|
-
DEFAULT_CONF:
|
4
|
-
id: 'map'
|
5
|
-
draggable: true
|
6
|
-
detect_location: false # should the browser attempt to use geolocation detection features of HTML5?
|
7
|
-
center_on_user: false # centers map on the location detected through the browser
|
8
|
-
center_latitude: 0
|
9
|
-
center_longitude: 0
|
10
|
-
zoom: 7
|
11
|
-
maxZoom: null
|
12
|
-
minZoom: null
|
13
|
-
auto_adjust : true # adjust the map to the markers if set to true
|
14
|
-
auto_zoom: true # zoom given by auto-adjust
|
15
|
-
bounds: [] # adjust map to these limits. Should be [{"lat": , "lng": }]
|
16
|
-
raw: {} # raw json to pass additional options
|
17
|
-
|
18
|
-
#to make the map fit the different LatLng points
|
19
|
-
adjustToBounds : ->
|
20
|
-
#reset previous bounds
|
21
|
-
@boundsObject = @createLatLngBounds()
|
22
|
-
|
23
|
-
#from markers
|
24
|
-
@extendBoundsWithMarkers()
|
25
|
-
|
26
|
-
#from polylines:
|
27
|
-
@extendBoundsWithPolylines()
|
28
|
-
|
29
|
-
#from polygons:
|
30
|
-
@extendBoundsWithPolygons()
|
31
|
-
|
32
|
-
#from circles
|
33
|
-
@extendBoundsWithCircles()
|
34
|
-
|
35
|
-
#in every case, I've to take into account the bounds set up by the user
|
36
|
-
@extendBoundsWithLatLng()
|
37
|
-
|
38
|
-
#SECOND_STEP: ajust the map to the bounds
|
39
|
-
@adaptToBounds()
|
40
|
-
|
41
|
-
extendBoundsWithMarkers : ->
|
42
|
-
for marker in @controller.markers
|
43
|
-
@extendBoundsWithMarker(marker) if marker.isVisible()
|
44
|
-
|
45
|
-
extendBoundsWithPolylines: ()->
|
46
|
-
for polyline in @controller.polylines
|
47
|
-
@extendBoundsWithPolyline(polyline) #if polyline.isVisible()
|
48
|
-
|
49
|
-
extendBoundsWithPolygons: ()->
|
50
|
-
for polygon in @controller.polygons
|
51
|
-
@extendBoundsWithPolygon(polygon) #if polygon.isVisible()
|
52
|
-
|
53
|
-
extendBoundsWithCircles: ()->
|
54
|
-
for circle in @controller.circles
|
55
|
-
@extendBoundsWithCircle(circle) #if circle.isVisible()
|
56
|
-
|
57
|
-
extendBoundsWithLatLng: ()->
|
58
|
-
for bound in @options.bounds
|
59
|
-
@extendBound bound
|
60
|
-
|
61
|
-
autoAdjustRequested: ->
|
62
|
-
@options.auto_adjust or @options.bounds.length > 0
|
@@ -1,24 +0,0 @@
|
|
1
|
-
@Gmaps4Rails.Marker = { }
|
2
|
-
|
3
|
-
@Gmaps4Rails.Marker.Class =
|
4
|
-
|
5
|
-
DEFAULT_CONF:
|
6
|
-
#Marker config
|
7
|
-
title: null
|
8
|
-
#MarkerImage config
|
9
|
-
picture : null
|
10
|
-
width: 22
|
11
|
-
length: 32
|
12
|
-
draggable: false
|
13
|
-
#clustering config
|
14
|
-
do_clustering: false # do clustering if set to true
|
15
|
-
randomize: false # Google maps can't display two markers which have the same coordinates. This randomizer enables to prevent this situation from happening.
|
16
|
-
max_random_distance: 100 # in meters. Each marker coordinate could be altered by this distance in a random direction
|
17
|
-
list_container: null # id of the ul that will host links to all markers
|
18
|
-
offset: 0 # used when adding_markers to an existing map. Because new markers are concated with previous one, offset is here to prevent the existing from being re-created.
|
19
|
-
raw: {} # raw json to pass additional options
|
20
|
-
|
21
|
-
@Gmaps4Rails.Marker.Instance =
|
22
|
-
|
23
|
-
getMap: ->
|
24
|
-
@controller.getMapObject()
|
@@ -1 +0,0 @@
|
|
1
|
-
#= require './bing/main'
|
@@ -1,29 +0,0 @@
|
|
1
|
-
#= require './shared'
|
2
|
-
|
3
|
-
#= require_tree './objects'
|
4
|
-
|
5
|
-
class @Gmaps4RailsBing extends Gmaps4Rails.BaseController
|
6
|
-
|
7
|
-
@include Gmaps4Rails.Bing.Shared
|
8
|
-
|
9
|
-
constructor: ->
|
10
|
-
super
|
11
|
-
|
12
|
-
|
13
|
-
getModule: ->
|
14
|
-
Gmaps4Rails.Bing
|
15
|
-
|
16
|
-
#////////////////////////////////////////////////////
|
17
|
-
#/////////////////// Clusterer //////////////////////
|
18
|
-
#////////////////////////////////////////////////////
|
19
|
-
|
20
|
-
createClusterer: (marker_serviceObject_array)->
|
21
|
-
|
22
|
-
clearClusterer: ->
|
23
|
-
|
24
|
-
#overwriting method from base controller since it doesn't fit here
|
25
|
-
clearMarkers: ->
|
26
|
-
|
27
|
-
#////////////////////////////////////////////////////
|
28
|
-
#/////////////// Private methods ////////////////////
|
29
|
-
#////////////////////////////////////////////////////
|