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,38 +0,0 @@
|
|
1
|
-
class @Gmaps4Rails.Google.Polygon extends Gmaps4Rails.Common
|
2
|
-
|
3
|
-
@include Gmaps4Rails.Interfaces.Basic
|
4
|
-
|
5
|
-
@include Gmaps4Rails.Google.Shared
|
6
|
-
@extend Gmaps4Rails.Polygon.Class
|
7
|
-
@extend Gmaps4Rails.Configuration
|
8
|
-
|
9
|
-
constructor : (polygon, controller) ->
|
10
|
-
@controller = controller
|
11
|
-
polygon_coordinates = []
|
12
|
-
|
13
|
-
#Polygon points are in an Array, that's why looping is necessary
|
14
|
-
for point in polygon
|
15
|
-
latlng = @createLatLng(point.lat, point.lng)
|
16
|
-
polygon_coordinates.push(latlng)
|
17
|
-
#first element of an Array could contain specific configuration for this particular polygon. If no config given, use default
|
18
|
-
if point == polygon[0]
|
19
|
-
strokeColor = point.strokeColor || @controller.polygons_conf.strokeColor
|
20
|
-
strokeOpacity = point.strokeOpacity || @controller.polygons_conf.strokeOpacity
|
21
|
-
strokeWeight = point.strokeWeight || @controller.polygons_conf.strokeWeight
|
22
|
-
fillColor = point.fillColor || @controller.polygons_conf.fillColor
|
23
|
-
fillOpacity = point.fillOpacity || @controller.polygons_conf.fillOpacity
|
24
|
-
clickable = point.clickable || @controller.polygons_conf.clickable
|
25
|
-
zIndex = point.zIndex || @controller.polygons_conf.zIndex
|
26
|
-
|
27
|
-
polyOptions =
|
28
|
-
path: polygon_coordinates
|
29
|
-
strokeColor: strokeColor
|
30
|
-
strokeOpacity: strokeOpacity
|
31
|
-
strokeWeight: strokeWeight
|
32
|
-
clickable: clickable
|
33
|
-
zIndex: zIndex
|
34
|
-
|
35
|
-
mergedOptions = @mergeObjects controller.polygons_conf.raw, polyOptions
|
36
|
-
|
37
|
-
@serviceObject = new google.maps.Polygon mergedOptions
|
38
|
-
@serviceObject.setMap(controller.getMapObject())
|
@@ -1,49 +0,0 @@
|
|
1
|
-
class @Gmaps4Rails.Google.Polyline extends Gmaps4Rails.Common
|
2
|
-
|
3
|
-
@include Gmaps4Rails.Interfaces.Basic
|
4
|
-
|
5
|
-
@include Gmaps4Rails.Google.Shared
|
6
|
-
@extend Gmaps4Rails.Polyline.Class
|
7
|
-
@extend Gmaps4Rails.Configuration
|
8
|
-
|
9
|
-
#creates a single polyline, triggered by create_polylines
|
10
|
-
constructor : (polyline, controller) ->
|
11
|
-
polyline_coordinates = []
|
12
|
-
#2 cases here, either we have a coded array of LatLng or we have an Array of LatLng
|
13
|
-
for element in polyline
|
14
|
-
#if we have a coded array
|
15
|
-
if element.coded_array?
|
16
|
-
decoded_array = new google.maps.geometry.encoding.decodePath(element.coded_array)
|
17
|
-
#loop through every point in the array
|
18
|
-
for point in decoded_array
|
19
|
-
polyline_coordinates.push(point)
|
20
|
-
|
21
|
-
#or we have an array of latlng
|
22
|
-
else
|
23
|
-
#by convention, a single polyline could be customized in the first array or it uses default values
|
24
|
-
if element == polyline[0]
|
25
|
-
strokeColor = element.strokeColor || controller.polylines_conf.strokeColor
|
26
|
-
strokeOpacity = element.strokeOpacity || controller.polylines_conf.strokeOpacity
|
27
|
-
strokeWeight = element.strokeWeight || controller.polylines_conf.strokeWeight
|
28
|
-
clickable = element.clickable || controller.polylines_conf.clickable
|
29
|
-
zIndex = element.zIndex || controller.polylines_conf.zIndex
|
30
|
-
icons = element.icons || controller.polylines_conf.icons
|
31
|
-
|
32
|
-
#add latlng if positions provided
|
33
|
-
if element.lat? && element.lng?
|
34
|
-
polyline_coordinates.push @createLatLng(element.lat, element.lng)
|
35
|
-
|
36
|
-
polyOptions =
|
37
|
-
path: polyline_coordinates
|
38
|
-
strokeColor: strokeColor
|
39
|
-
strokeOpacity: strokeOpacity
|
40
|
-
strokeWeight: strokeWeight
|
41
|
-
clickable: clickable
|
42
|
-
zIndex: zIndex
|
43
|
-
icons: icons
|
44
|
-
|
45
|
-
mergedOptions = @mergeObjects controller.polylines_conf.raw, polyOptions
|
46
|
-
|
47
|
-
# Construct the polyline
|
48
|
-
@serviceObject = new google.maps.Polyline mergedOptions
|
49
|
-
@serviceObject.setMap(controller.getMapObject())
|
@@ -1,27 +0,0 @@
|
|
1
|
-
Gmaps4Rails.Google = {}
|
2
|
-
|
3
|
-
Gmaps4Rails.Google.Shared =
|
4
|
-
|
5
|
-
createPoint : (lat, lng) ->
|
6
|
-
new google.maps.Point(lat, lng)
|
7
|
-
|
8
|
-
createSize : (width, height) ->
|
9
|
-
new google.maps.Size(width, height)
|
10
|
-
|
11
|
-
createLatLng : (lat, lng) ->
|
12
|
-
new google.maps.LatLng(lat, lng)
|
13
|
-
|
14
|
-
createLatLngBounds : ->
|
15
|
-
new google.maps.LatLngBounds()
|
16
|
-
|
17
|
-
clear: ()->
|
18
|
-
@serviceObject.setMap(null)
|
19
|
-
|
20
|
-
show: () ->
|
21
|
-
@serviceObject.setVisible(true)
|
22
|
-
|
23
|
-
hide: () ->
|
24
|
-
@serviceObject.setVisible(false)
|
25
|
-
|
26
|
-
isVisible: ->
|
27
|
-
@serviceObject.getVisible()
|
@@ -1 +0,0 @@
|
|
1
|
-
#= require './openlayers/main'
|
@@ -1,138 +0,0 @@
|
|
1
|
-
#= require './shared'
|
2
|
-
|
3
|
-
#= require_tree './objects'
|
4
|
-
|
5
|
-
class @Gmaps4RailsOpenlayers extends Gmaps4Rails.BaseController
|
6
|
-
|
7
|
-
@include Gmaps4Rails.Openlayers.Shared
|
8
|
-
|
9
|
-
constructor: ->
|
10
|
-
super
|
11
|
-
|
12
|
-
@markersControl = null
|
13
|
-
@markersLayer = null
|
14
|
-
|
15
|
-
@polylinesLayer = null
|
16
|
-
|
17
|
-
getModule: ->
|
18
|
-
Gmaps4Rails.Openlayers
|
19
|
-
|
20
|
-
#////////////////////////////////////////////////////
|
21
|
-
#/////////////////// Clusterer //////////////////////
|
22
|
-
#////////////////////////////////////////////////////
|
23
|
-
|
24
|
-
createClusterer: (marker_serviceObject_array)->
|
25
|
-
style = new OpenLayers.Style @_clustererOptions, @_clustererFunctions
|
26
|
-
|
27
|
-
strategy = new OpenLayers.Strategy.Cluster
|
28
|
-
@_clearMarkersLayer()
|
29
|
-
|
30
|
-
@clusterLayer = new OpenLayers.Layer.Vector "Clusters",
|
31
|
-
strategies: [strategy]
|
32
|
-
styleMap: new OpenLayers.StyleMap
|
33
|
-
"default": style
|
34
|
-
"select":
|
35
|
-
fillColor: "#8aeeef"
|
36
|
-
strokeColor: "#32a8a9"
|
37
|
-
|
38
|
-
@getMapObject().addLayer @clusterLayer
|
39
|
-
@clusterLayer.addFeatures marker_serviceObject_array
|
40
|
-
@clusterLayer
|
41
|
-
|
42
|
-
clearClusterer: ->
|
43
|
-
@getMapObject().removeLayer @markerClusterer if @clusterLayer? and @getMapObject().getLayer(@clusterLayer.id)?
|
44
|
-
@clusterLayer = null
|
45
|
-
|
46
|
-
#overwriting method from base controller since it doesn't fit here
|
47
|
-
clearMarkers: ->
|
48
|
-
@_clearMarkersLayer()
|
49
|
-
@clearClusterer()
|
50
|
-
@markers = []
|
51
|
-
|
52
|
-
#////////////////////////////////////////////////////
|
53
|
-
#/////////////// Private methods ////////////////////
|
54
|
-
#////////////////////////////////////////////////////
|
55
|
-
|
56
|
-
_createPolylinesLayer: ->
|
57
|
-
|
58
|
-
return if @polylinesLayer?
|
59
|
-
@polylinesLayer = new OpenLayers.Layer.Vector("Polylines", null)
|
60
|
-
@polylinesLayer.events.register("featureselected", @polylinesLayer, @_onFeatureSelect)
|
61
|
-
@polylinesLayer.events.register("featureunselected", @polylinesLayer, @_onFeatureUnselect)
|
62
|
-
@polylinesControl = new OpenLayers.Control.DrawFeature(@polylinesLayer, OpenLayers.Handler.Path)
|
63
|
-
@getMapObject().addLayer(@polylinesLayer)
|
64
|
-
|
65
|
-
@getMapObject().addControl(@polylinesControl)
|
66
|
-
|
67
|
-
_createMarkersLayer: ->
|
68
|
-
return if @markersLayer?
|
69
|
-
|
70
|
-
@markersLayer = new OpenLayers.Layer.Vector("Markers", null)
|
71
|
-
@getMapObject().addLayer @markersLayer
|
72
|
-
|
73
|
-
@markersLayer.events.register("featureselected", @markersLayer, @_onFeatureSelect())
|
74
|
-
@markersLayer.events.register("featureunselected", @markersLayer, @_onFeatureUnselect())
|
75
|
-
|
76
|
-
@markersControl = new OpenLayers.Control.SelectFeature @markersLayer
|
77
|
-
|
78
|
-
@getMapObject().addControl @markersControl
|
79
|
-
@markersControl.activate()
|
80
|
-
|
81
|
-
_clearMarkersLayer: ->
|
82
|
-
@getMapObject().removeLayer(@markersLayer) if @markersLayer? and @getMapObject().getLayer(@markersLayer.id)?
|
83
|
-
@markersLayer = null
|
84
|
-
|
85
|
-
_onFeatureSelect: ->
|
86
|
-
controller = @
|
87
|
-
return (evt) ->
|
88
|
-
feature = evt.feature
|
89
|
-
|
90
|
-
popup = new OpenLayers.Popup.FramedCloud(
|
91
|
-
"featurePopup",
|
92
|
-
feature.geometry.getBounds().getCenterLonLat(),
|
93
|
-
new OpenLayers.Size(300,200),
|
94
|
-
feature.infoWindow,
|
95
|
-
null,
|
96
|
-
true,
|
97
|
-
controller._onPopupClose(controller, feature)
|
98
|
-
)
|
99
|
-
feature.popup = popup
|
100
|
-
popup.feature = feature
|
101
|
-
controller.getMapObject().addPopup popup
|
102
|
-
|
103
|
-
_onFeatureUnselect: ->
|
104
|
-
controller = @
|
105
|
-
|
106
|
-
return (evt)->
|
107
|
-
feature = evt.feature
|
108
|
-
|
109
|
-
if feature.popup?
|
110
|
-
controller.getMapObject().removePopup feature.popup
|
111
|
-
feature.popup.destroy()
|
112
|
-
feature.popup = null
|
113
|
-
|
114
|
-
_onPopupClose: (controller, feature) ->
|
115
|
-
return ->
|
116
|
-
controller.markersControl.unselect feature
|
117
|
-
|
118
|
-
_clustererFunctions:
|
119
|
-
context:
|
120
|
-
width: (feature) ->
|
121
|
-
return (feature.cluster) ? 2 : 1
|
122
|
-
radius: (feature) ->
|
123
|
-
pix = 2
|
124
|
-
pix = feature.cluster.length + 10 if feature.cluster
|
125
|
-
return pix
|
126
|
-
label: (feature) ->
|
127
|
-
if feature.cluster
|
128
|
-
return feature.cluster.length
|
129
|
-
else
|
130
|
-
return ""
|
131
|
-
|
132
|
-
_clustererOptions:
|
133
|
-
pointRadius: "${radius}"
|
134
|
-
fillColor: "#ffcc66"
|
135
|
-
fillOpacity: 0.8
|
136
|
-
strokeColor: "#cc6633"
|
137
|
-
strokeWidth: "${width}"
|
138
|
-
label: "${label}"
|
@@ -1,49 +0,0 @@
|
|
1
|
-
class @Gmaps4Rails.Openlayers.Map extends Gmaps4Rails.Common
|
2
|
-
|
3
|
-
@include Gmaps4Rails.Interfaces.Map
|
4
|
-
|
5
|
-
@include Gmaps4Rails.Map
|
6
|
-
@include Gmaps4Rails.Openlayers.Shared
|
7
|
-
@include Gmaps4Rails.Configuration
|
8
|
-
|
9
|
-
CONF:
|
10
|
-
disableDefaultUI: false
|
11
|
-
disableDoubleClickZoom: false
|
12
|
-
type: "ROADMAP" # HYBRID, ROADMAP, SATELLITE, TERRAIN
|
13
|
-
mapTypeControl: null
|
14
|
-
|
15
|
-
constructor:(map_options, controller) ->
|
16
|
-
@controller = controller
|
17
|
-
|
18
|
-
defaultOptions = @setConf()
|
19
|
-
@options = @mergeObjects map_options, defaultOptions
|
20
|
-
|
21
|
-
openlayersOptions =
|
22
|
-
center: @createLatLng(@options.center_latitude, @options.center_longitude)
|
23
|
-
zoom: @options.zoom
|
24
|
-
|
25
|
-
mergedOpenlayersOptions = @mergeObjects map_options.raw, openlayersOptions
|
26
|
-
|
27
|
-
@serviceObject = new OpenLayers.Map(@options.id, mergedOpenlayersOptions)
|
28
|
-
|
29
|
-
@serviceObject.addLayer(new OpenLayers.Layer.OSM())
|
30
|
-
|
31
|
-
extendBoundsWithMarker : (marker)->
|
32
|
-
@boundsObject.extend(@createLatLng(marker.lat,marker.lng))
|
33
|
-
|
34
|
-
extendBoundsWithPolyline: (polyline)->
|
35
|
-
|
36
|
-
extendBoundsWithPolygon: (polygon)->
|
37
|
-
|
38
|
-
extendBoundsWithCircle: (circle)->
|
39
|
-
|
40
|
-
extendBound: (bound)->
|
41
|
-
|
42
|
-
fitBounds: ->
|
43
|
-
@serviceObject.zoomToExtent(@boundsObject, true)
|
44
|
-
|
45
|
-
adaptToBounds: ->
|
46
|
-
@fitBounds()
|
47
|
-
|
48
|
-
centerMapOnUser : (position)->
|
49
|
-
@serviceObject.setCenter position
|
@@ -1,68 +0,0 @@
|
|
1
|
-
class @Gmaps4Rails.Openlayers.Marker extends Gmaps4Rails.Common
|
2
|
-
|
3
|
-
@include Gmaps4Rails.Interfaces.Marker
|
4
|
-
|
5
|
-
@include Gmaps4Rails.Openlayers.Shared
|
6
|
-
@include Gmaps4Rails.Marker.Instance
|
7
|
-
@extend Gmaps4Rails.Marker.Class
|
8
|
-
@extend Gmaps4Rails.Configuration
|
9
|
-
|
10
|
-
|
11
|
-
constructor: (args, controller)->
|
12
|
-
@controller = controller
|
13
|
-
|
14
|
-
@controller._createMarkersLayer()
|
15
|
-
|
16
|
-
@_createMarkerStyle(args)
|
17
|
-
|
18
|
-
if @_isBasicMarker(args)
|
19
|
-
@_styleForBasicMarker(args)
|
20
|
-
else
|
21
|
-
@_styleForCustomMarker(args)
|
22
|
-
|
23
|
-
@serviceObject = new OpenLayers.Feature.Vector(
|
24
|
-
@createPoint(args.lat, args.lng),
|
25
|
-
null,
|
26
|
-
@style_mark
|
27
|
-
)
|
28
|
-
#//changing coordinates so that it actually appears on the map!
|
29
|
-
@serviceObject.geometry.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913"))
|
30
|
-
#//adding layer to the map
|
31
|
-
@controller.markersLayer.addFeatures([@serviceObject])
|
32
|
-
|
33
|
-
createInfoWindow : () ->
|
34
|
-
@serviceObject.infoWindow = @description if @description?
|
35
|
-
|
36
|
-
#cheap integration, I admit
|
37
|
-
isVisible: ->
|
38
|
-
true
|
39
|
-
|
40
|
-
_isBasicMarker: (args)->
|
41
|
-
!args.marker_picture?
|
42
|
-
|
43
|
-
_createMarkerStyle: (args) ->
|
44
|
-
@style_mark = OpenLayers.Util.extend({}, OpenLayers.Feature.Vector.style['default'])
|
45
|
-
@style_mark.fillOpacity = 1
|
46
|
-
@style_mark.graphicTitle = args.marker_title
|
47
|
-
|
48
|
-
_styleForBasicMarker: (args)->
|
49
|
-
@style_mark.graphicHeight = 30
|
50
|
-
@style_mark.externalGraphic = "http://openlayers.org/dev/img/marker-blue.png"
|
51
|
-
|
52
|
-
_styleForCustomMarker: (args)->
|
53
|
-
@style_mark.graphicWidth = args.marker_width
|
54
|
-
@style_mark.graphicHeight = args.marker_height
|
55
|
-
@style_mark.externalGraphic = args.marker_picture
|
56
|
-
#//adding anchor if any
|
57
|
-
if args.marker_anchor?
|
58
|
-
@style_mark.graphicXOffset = args.marker_anchor[0]
|
59
|
-
@style_mark.graphicYOffset = args.marker_anchor[1]
|
60
|
-
#//adding shadow if any
|
61
|
-
if args.shadow_picture?
|
62
|
-
@style_mark.backgroundGraphic = args.shadow_picture
|
63
|
-
@style_mark.backgroundWidth = args.shadow_width
|
64
|
-
@style_mark.backgroundHeight = args.shadow_height
|
65
|
-
#//adding shadow's anchor if any
|
66
|
-
if args.shadow_anchor?
|
67
|
-
@style_mark.backgroundXOffset = args.shadow_anchor[0]
|
68
|
-
@style_mark.backgroundYOffset = args.shadow_anchor[1]
|
@@ -1,39 +0,0 @@
|
|
1
|
-
class @Gmaps4Rails.Openlayers.Polyline extends Gmaps4Rails.Common
|
2
|
-
|
3
|
-
@include Gmaps4Rails.Interfaces.Basic
|
4
|
-
|
5
|
-
@include Gmaps4Rails.Openlayers.Shared
|
6
|
-
@extend Gmaps4Rails.Polyline.Class
|
7
|
-
@extend Gmaps4Rails.Configuration
|
8
|
-
|
9
|
-
#creates a single polyline, triggered by create_polylines
|
10
|
-
constructor : (polyline, controller) ->
|
11
|
-
@controller = controller
|
12
|
-
@controller._createPolylinesLayer()
|
13
|
-
|
14
|
-
polyline_coordinates = []
|
15
|
-
|
16
|
-
for element in polyline
|
17
|
-
#by convention, a single polyline could be customized in the first array or it uses default values
|
18
|
-
if element == polyline[0]
|
19
|
-
strokeColor = element.strokeColor || @controller.polylines_conf.strokeColor
|
20
|
-
strokeOpacity = element.strokeOpacity || @controller.polylines_conf.strokeOpacity
|
21
|
-
strokeWeight = element.strokeWeight || @controller.polylines_conf.strokeWeight
|
22
|
-
clickable = element.clickable || @controller.polylines_conf.clickable
|
23
|
-
zIndex = element.zIndex || @controller.polylines_conf.zIndex
|
24
|
-
|
25
|
-
#add latlng if positions provided
|
26
|
-
if element.lat? && element.lng?
|
27
|
-
latlng = new OpenLayers.Geometry.Point(element.lng, element.lat)
|
28
|
-
polyline_coordinates.push(latlng)
|
29
|
-
|
30
|
-
line_points = new OpenLayers.Geometry.LineString(polyline_coordinates);
|
31
|
-
line_style = { strokeColor: strokeColor, strokeOpacity: strokeOpacity, strokeWidth: strokeWeight };
|
32
|
-
|
33
|
-
@serviceObject = new OpenLayers.Feature.Vector(line_points, null, line_style);
|
34
|
-
@serviceObject.geometry.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913"))
|
35
|
-
|
36
|
-
@controller.polylinesLayer.addFeatures([@serviceObject])
|
37
|
-
|
38
|
-
isVisible: ->
|
39
|
-
true
|
@@ -1,19 +0,0 @@
|
|
1
|
-
Gmaps4Rails.Openlayers = {}
|
2
|
-
|
3
|
-
Gmaps4Rails.Openlayers.Shared =
|
4
|
-
|
5
|
-
createPoint:(lat, lng) ->
|
6
|
-
new OpenLayers.Geometry.Point(lng, lat)
|
7
|
-
|
8
|
-
createLatLng: (lat, lng)->
|
9
|
-
new OpenLayers.LonLat(lng, lat).transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913")) # transform from WGS 1984 to Spherical Mercator Projection
|
10
|
-
|
11
|
-
createAnchor: (offset)->
|
12
|
-
return null if offset == null
|
13
|
-
new OpenLayers.Pixel(offset[0], offset[1])
|
14
|
-
|
15
|
-
createSize: (width, height)->
|
16
|
-
new OpenLayers.Size(width, height)
|
17
|
-
|
18
|
-
createLatLngBounds: ->
|
19
|
-
new OpenLayers.Bounds()
|