gmaps4rails 1.5.7 → 1.5.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- metadata +6 -386
- data/.gitignore +0 -17
- data/.travis.yml +0 -10
- data/Gemfile +0 -9
- data/Gemfile.lock +0 -182
- data/Guardfile +0 -24
- data/MIT-LICENSE +0 -20
- data/README.rdoc +0 -135
- data/Rakefile +0 -4
- data/app/assets/javascripts/gmaps4rails/gmaps4rails.base.js.coffee +0 -444
- data/app/assets/javascripts/gmaps4rails/gmaps4rails.bing.js.coffee +0 -174
- data/app/assets/javascripts/gmaps4rails/gmaps4rails.googlemaps.js.coffee +0 -339
- data/app/assets/javascripts/gmaps4rails/gmaps4rails.mapquest.js.coffee +0 -145
- data/app/assets/javascripts/gmaps4rails/gmaps4rails.openlayers.js.coffee +0 -261
- data/app/views/gmaps4rails/_gmaps4rails.html.erb +0 -20
- data/gmaps4rails.gemspec +0 -39
- data/lib/generators/gmaps4rails/install_generator.rb +0 -48
- data/lib/generators/templates/README +0 -2
- data/lib/gmaps4rails.rb +0 -26
- 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 -119
- 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 -157
- data/lib/gmaps4rails/json_builder.rb +0 -140
- data/lib/gmaps4rails/model_handler.rb +0 -101
- data/lib/gmaps4rails/version.rb +0 -3
- data/lib/gmaps4rails/view_helper.rb +0 -175
- data/lib/tasks/gmaps4rails_tasks.rake +0 -4
- data/lib/tasks/jasmine.rake +0 -8
- data/public/javascripts/gmaps4rails/gmaps4rails.base.js +0 -464
- data/public/javascripts/gmaps4rails/gmaps4rails.bing.js +0 -226
- data/public/javascripts/gmaps4rails/gmaps4rails.googlemaps.js +0 -430
- data/public/javascripts/gmaps4rails/gmaps4rails.mapquest.js +0 -178
- data/public/javascripts/gmaps4rails/gmaps4rails.openlayers.js +0 -265
- data/public/stylesheets/gmaps4rails.css +0 -24
- data/spec/dummy/.gitignore +0 -2
- 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 -15
- 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 -101
- 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 -16
- data/spec/dummy/app/views/users/_form.html.erb +0 -37
- data/spec/dummy/app/views/users/_map.html.erb +0 -5
- data/spec/dummy/app/views/users/edit.html.erb +0 -6
- data/spec/dummy/app/views/users/index.html.erb +0 -260
- 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/javascripts/basic_methods_spec.js +0 -103
- data/spec/javascripts/helpers/.gitkeep +0 -0
- data/spec/javascripts/helpers/SpecHelper.js +0 -87
- data/spec/javascripts/map_spec.js +0 -49
- data/spec/javascripts/markers_methods_spec.js +0 -368
- data/spec/javascripts/mocks_spec.js +0 -27
- data/spec/javascripts/support/jasmine.yml +0 -10
- data/spec/javascripts/support/jasmine_config.rb +0 -23
- data/spec/javascripts/support/jasmine_runner.rb +0 -20
- 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/base_spec.rb +0 -59
- data/spec/lib/direction_spec.rb +0 -53
- data/spec/lib/geocoder_spec.rb +0 -46
- data/spec/lib/js_builder_spec.rb +0 -139
- data/spec/lib/json_builder_spec.rb +0 -232
- data/spec/lib/places_spec.rb +0 -25
- data/spec/models/place_spec.rb +0 -35
- data/spec/models/user_spec.rb +0 -187
- data/spec/spec_helper.rb +0 -44
- data/spec/support/geocoding.rb +0 -41
- data/spec/support/matchers.rb +0 -73
@@ -1,174 +0,0 @@
|
|
1
|
-
######################################################################################################
|
2
|
-
############################################## Bing Maps ##########################################
|
3
|
-
######################################################################################################
|
4
|
-
|
5
|
-
#// http://wiki.openstreetmap.org/wiki/OpenLayers
|
6
|
-
#// http://openlayers.org/dev/examples
|
7
|
-
#//http://docs.openlayers.org/contents.html
|
8
|
-
|
9
|
-
class @Gmaps4RailsBing extends Gmaps4Rails
|
10
|
-
|
11
|
-
constructor: ->
|
12
|
-
super
|
13
|
-
@map_options =
|
14
|
-
type: "road" # aerial, auto, birdseye, collinsBart, mercator, ordnanceSurvey, road
|
15
|
-
@markers_conf =
|
16
|
-
infobox: "description" #description or htmlContent
|
17
|
-
|
18
|
-
@mergeWithDefault("map_options")
|
19
|
-
@mergeWithDefault("markers_conf")
|
20
|
-
|
21
|
-
#////////////////////////////////////////////////////
|
22
|
-
#/////////////// Basic Objects //////////////
|
23
|
-
#////////////////////////////////////////////////////
|
24
|
-
|
25
|
-
getMapType: ->
|
26
|
-
switch @map_options.type
|
27
|
-
when "road" then return Microsoft.Maps.MapTypeId.road
|
28
|
-
when "aerial" then return Microsoft.Maps.MapTypeId.aerial
|
29
|
-
when "auto" then return Microsoft.Maps.MapTypeId.auto
|
30
|
-
when "birdseye" then return Microsoft.Maps.MapTypeId.birdseye
|
31
|
-
when "collinsBart" then return Microsoft.Maps.MapTypeId.collinsBart
|
32
|
-
when "mercator" then return Microsoft.Maps.MapTypeId.mercator
|
33
|
-
when "ordnanceSurvey" then return Microsoft.Maps.MapTypeId.ordnanceSurvey
|
34
|
-
else return Microsoft.Maps.MapTypeId.auto
|
35
|
-
|
36
|
-
createPoint: (lat, lng) ->
|
37
|
-
return new Microsoft.Maps.Point(lat, lng)
|
38
|
-
|
39
|
-
createLatLng:(lat, lng) ->
|
40
|
-
return new Microsoft.Maps.Location(lat, lng)
|
41
|
-
|
42
|
-
createLatLngBounds: ->
|
43
|
-
|
44
|
-
createMap: ->
|
45
|
-
return new Microsoft.Maps.Map(document.getElementById(@map_options.id), {
|
46
|
-
credentials: @map_options.provider_key,
|
47
|
-
mapTypeId: @getMapType(),
|
48
|
-
center: @createLatLng(@map_options.center_latitude, @map_options.center_longitude),
|
49
|
-
zoom: @map_options.zoom
|
50
|
-
})
|
51
|
-
|
52
|
-
createSize: (width, height) ->
|
53
|
-
return new google.maps.Size(width, height)
|
54
|
-
|
55
|
-
#////////////////////////////////////////////////////
|
56
|
-
#////////////////////// Markers /////////////////////
|
57
|
-
#////////////////////////////////////////////////////
|
58
|
-
|
59
|
-
createMarker: (args) ->
|
60
|
-
markerLatLng = @createLatLng(args.Lat, args.Lng)
|
61
|
-
marker
|
62
|
-
#// Marker sizes are expressed as a Size of X,Y
|
63
|
-
if args.marker_picture == ""
|
64
|
-
marker = new Microsoft.Maps.Pushpin(@createLatLng(args.Lat, args.Lng), {
|
65
|
-
draggable: args.marker_draggable,
|
66
|
-
anchor: @createImageAnchorPosition(args.Lat, args.Lng),
|
67
|
-
text: args.marker_title
|
68
|
-
}
|
69
|
-
);
|
70
|
-
else
|
71
|
-
marker = new Microsoft.Maps.Pushpin(@createLatLng(args.Lat, args.Lng), {
|
72
|
-
draggable: args.marker_draggable,
|
73
|
-
anchor: @createImageAnchorPosition(args.Lat, args.Lng),
|
74
|
-
icon: args.marker_picture,
|
75
|
-
height: args.marker_height,
|
76
|
-
text: args.marker_title,
|
77
|
-
width: args.marker_width
|
78
|
-
}
|
79
|
-
);
|
80
|
-
@addToMap(marker)
|
81
|
-
return marker
|
82
|
-
|
83
|
-
#// clear markers
|
84
|
-
clearMarkers: ->
|
85
|
-
for marker in @markers
|
86
|
-
@clearMarker marker
|
87
|
-
|
88
|
-
clearMarker: (marker) ->
|
89
|
-
@removeFromMap(marker.serviceObject)
|
90
|
-
|
91
|
-
#//show and hide markers
|
92
|
-
showMarkers: ->
|
93
|
-
for marker in @markers
|
94
|
-
@showMarker marker
|
95
|
-
|
96
|
-
showMarker: (marker) ->
|
97
|
-
marker.serviceObject.setOptions({ visible: true })
|
98
|
-
|
99
|
-
hideMarkers: ->
|
100
|
-
for marker in @markers
|
101
|
-
@hideMarker marker
|
102
|
-
|
103
|
-
hideMarker: (marker) ->
|
104
|
-
marker.serviceObject.setOptions({ visible: false })
|
105
|
-
|
106
|
-
extendBoundsWithMarkers: ->
|
107
|
-
locationsArray = []
|
108
|
-
for marker in @markers
|
109
|
-
locationsArray.push(marker.serviceObject.getLocation())
|
110
|
-
@boundsObject = Microsoft.Maps.LocationRect.fromLocations(locationsArray)
|
111
|
-
|
112
|
-
#////////////////////////////////////////////////////
|
113
|
-
#/////////////////// Clusterer //////////////////////
|
114
|
-
#////////////////////////////////////////////////////
|
115
|
-
|
116
|
-
createClusterer: (markers_array) ->
|
117
|
-
|
118
|
-
clearClusterer: ->
|
119
|
-
|
120
|
-
#//creates clusters
|
121
|
-
clusterize: ->
|
122
|
-
|
123
|
-
#////////////////////////////////////////////////////
|
124
|
-
#/////////////////// INFO WINDOW ////////////////////
|
125
|
-
#////////////////////////////////////////////////////
|
126
|
-
|
127
|
-
#// creates infowindows
|
128
|
-
createInfoWindow: (marker_container) ->
|
129
|
-
if marker_container.description?
|
130
|
-
#//create the infowindow
|
131
|
-
if @markers_conf.infobox == "description"
|
132
|
-
marker_container.info_window = new Microsoft.Maps.Infobox(marker_container.serviceObject.getLocation(), { description: marker_container.description, visible: false, showCloseButton: true})
|
133
|
-
else
|
134
|
-
marker_container.info_window = new Microsoft.Maps.Infobox(marker_container.serviceObject.getLocation(), { htmlContent: marker_container.description, visible: false})
|
135
|
-
|
136
|
-
#//add the listener associated
|
137
|
-
currentMap = this
|
138
|
-
Microsoft.Maps.Events.addHandler(marker_container.serviceObject, 'click', @openInfoWindow(currentMap, marker_container.info_window))
|
139
|
-
@addToMap(marker_container.info_window)
|
140
|
-
|
141
|
-
openInfoWindow: (currentMap, infoWindow) ->
|
142
|
-
return ->
|
143
|
-
# Close the latest selected marker before opening the current one.
|
144
|
-
if currentMap.visibleInfoWindow
|
145
|
-
currentMap.visibleInfoWindow.setOptions({ visible: false })
|
146
|
-
infoWindow.setOptions({ visible:true })
|
147
|
-
currentMap.visibleInfoWindow = infoWindow
|
148
|
-
|
149
|
-
#////////////////////////////////////////////////////
|
150
|
-
#/////////////////// Other methods //////////////////
|
151
|
-
#////////////////////////////////////////////////////
|
152
|
-
|
153
|
-
fitBounds: ->
|
154
|
-
@serviceObject.setView({bounds: @boundsObject})
|
155
|
-
|
156
|
-
addToMap: (object)->
|
157
|
-
@serviceObject.entities.push(object)
|
158
|
-
|
159
|
-
removeFromMap: (object)->
|
160
|
-
@serviceObject.entities.remove(object)
|
161
|
-
|
162
|
-
centerMapOnUser: ->
|
163
|
-
@serviceObject.setView({ center: @userLocation})
|
164
|
-
|
165
|
-
updateBoundsWithPolylines: ()->
|
166
|
-
|
167
|
-
updateBoundsWithPolygons: ()->
|
168
|
-
|
169
|
-
updateBoundsWithCircles: ()->
|
170
|
-
|
171
|
-
extendMapBounds :->
|
172
|
-
|
173
|
-
adaptMapToBounds: ->
|
174
|
-
@fitBounds()
|
@@ -1,339 +0,0 @@
|
|
1
|
-
#######################################################################################################
|
2
|
-
############################################## Google maps ##########################################
|
3
|
-
#######################################################################################################
|
4
|
-
|
5
|
-
class @Gmaps4RailsGoogle extends Gmaps4Rails
|
6
|
-
|
7
|
-
constructor: ->
|
8
|
-
super
|
9
|
-
#Map settings
|
10
|
-
@map_options =
|
11
|
-
disableDefaultUI: false
|
12
|
-
disableDoubleClickZoom: false
|
13
|
-
type: "ROADMAP" # HYBRID, ROADMAP, SATELLITE, TERRAIN
|
14
|
-
|
15
|
-
#markers + info styling
|
16
|
-
@markers_conf =
|
17
|
-
clusterer_gridSize: 50
|
18
|
-
clusterer_maxZoom: 5
|
19
|
-
custom_cluster_pictures: null
|
20
|
-
custom_infowindow_class: null
|
21
|
-
|
22
|
-
@mergeWithDefault("map_options")
|
23
|
-
@mergeWithDefault("markers_conf")
|
24
|
-
|
25
|
-
@kml_options =
|
26
|
-
clickable: true
|
27
|
-
preserveViewport: false
|
28
|
-
suppressInfoWindows: false
|
29
|
-
|
30
|
-
#Polygon Styling
|
31
|
-
@polygons_conf = # default style for polygons
|
32
|
-
strokeColor: "#FFAA00"
|
33
|
-
strokeOpacity: 0.8
|
34
|
-
strokeWeight: 2
|
35
|
-
fillColor: "#000000"
|
36
|
-
fillOpacity: 0.35
|
37
|
-
clickable: false
|
38
|
-
|
39
|
-
#Circle Styling
|
40
|
-
@circles_conf = #default style for circles
|
41
|
-
fillColor: "#00AAFF"
|
42
|
-
fillOpacity: 0.35
|
43
|
-
strokeColor: "#FFAA00"
|
44
|
-
strokeOpacity: 0.8
|
45
|
-
strokeWeight: 2
|
46
|
-
clickable: false
|
47
|
-
zIndex: null
|
48
|
-
|
49
|
-
#Direction Settings
|
50
|
-
@direction_conf =
|
51
|
-
panel_id: null
|
52
|
-
display_panel: false
|
53
|
-
origin: null
|
54
|
-
destination: null
|
55
|
-
waypoints: [] #[{location: "toulouse,fr", stopover: true}, {location: "Clermont-Ferrand, fr", stopover: true}]
|
56
|
-
optimizeWaypoints: false
|
57
|
-
unitSystem: "METRIC" #IMPERIAL
|
58
|
-
avoidHighways: false
|
59
|
-
avoidTolls: false
|
60
|
-
region: null
|
61
|
-
travelMode: "DRIVING" #WALKING, BICYCLING
|
62
|
-
|
63
|
-
#////////////////////////////////////////////////////
|
64
|
-
#/////////////// Basic Objects //////////////
|
65
|
-
#////////////////////////////////////////////////////
|
66
|
-
|
67
|
-
createPoint : (lat, lng) ->
|
68
|
-
return new google.maps.Point(lat, lng)
|
69
|
-
|
70
|
-
createLatLng : (lat, lng) ->
|
71
|
-
return new google.maps.LatLng(lat, lng)
|
72
|
-
|
73
|
-
createLatLngBounds : ->
|
74
|
-
return new google.maps.LatLngBounds()
|
75
|
-
|
76
|
-
createMap : ->
|
77
|
-
defaultOptions =
|
78
|
-
maxZoom: @map_options.maxZoom
|
79
|
-
minZoom: @map_options.minZoom
|
80
|
-
zoom: @map_options.zoom
|
81
|
-
center: @createLatLng(@map_options.center_latitude, @map_options.center_longitude)
|
82
|
-
mapTypeId: google.maps.MapTypeId[@map_options.type]
|
83
|
-
mapTypeControl: @map_options.mapTypeControl
|
84
|
-
disableDefaultUI: @map_options.disableDefaultUI
|
85
|
-
disableDoubleClickZoom: @map_options.disableDoubleClickZoom
|
86
|
-
draggable: @map_options.draggable
|
87
|
-
|
88
|
-
mergedOptions = @mergeObjectWithDefault @map_options.raw, defaultOptions
|
89
|
-
|
90
|
-
return new google.maps.Map document.getElementById(@map_options.id), mergedOptions
|
91
|
-
|
92
|
-
|
93
|
-
createMarkerImage : (markerPicture, markerSize, origin, anchor, scaledSize) ->
|
94
|
-
return new google.maps.MarkerImage(markerPicture, markerSize, origin, anchor, scaledSize)
|
95
|
-
|
96
|
-
createSize : (width, height) ->
|
97
|
-
return new google.maps.Size(width, height)
|
98
|
-
|
99
|
-
#////////////////////////////////////////////////////
|
100
|
-
#////////////////////// Markers /////////////////////
|
101
|
-
#////////////////////////////////////////////////////
|
102
|
-
|
103
|
-
createMarker : (args) ->
|
104
|
-
markerLatLng = @createLatLng(args.Lat, args.Lng)
|
105
|
-
#Marker sizes are expressed as a Size of X,Y
|
106
|
-
if args.marker_picture == "" and args.rich_marker == null
|
107
|
-
defaultOptions = {position: markerLatLng, map: @serviceObject, title: args.marker_title, draggable: args.marker_draggable, zIndex: args.zindex}
|
108
|
-
mergedOptions = @mergeObjectWithDefault @markers_conf.raw, defaultOptions
|
109
|
-
return new google.maps.Marker mergedOptions
|
110
|
-
|
111
|
-
if (args.rich_marker != null)
|
112
|
-
return new RichMarker({
|
113
|
-
position: markerLatLng
|
114
|
-
map: @serviceObject
|
115
|
-
draggable: args.marker_draggable
|
116
|
-
content: args.rich_marker
|
117
|
-
flat: if args.marker_anchor == null then false else args.marker_anchor[1]
|
118
|
-
anchor: if args.marker_anchor == null then 0 else args.marker_anchor[0]
|
119
|
-
zIndex: args.zindex
|
120
|
-
})
|
121
|
-
|
122
|
-
#default behavior
|
123
|
-
#calculate MarkerImage anchor location
|
124
|
-
imageAnchorPosition = @createImageAnchorPosition args.marker_anchor
|
125
|
-
shadowAnchorPosition = @createImageAnchorPosition args.shadow_anchor
|
126
|
-
#create or retrieve existing MarkerImages
|
127
|
-
markerImage = @createOrRetrieveImage(args.marker_picture, args.marker_width, args.marker_height, imageAnchorPosition)
|
128
|
-
shadowImage = @createOrRetrieveImage(args.shadow_picture, args.shadow_width, args.shadow_height, shadowAnchorPosition)
|
129
|
-
defaultOptions = {position: markerLatLng, map: @serviceObject, icon: markerImage, title: args.marker_title, draggable: args.marker_draggable, shadow: shadowImage, zIndex: args.zindex}
|
130
|
-
mergedOptions = @mergeObjectWithDefault @markers_conf.raw, defaultOptions
|
131
|
-
return new google.maps.Marker mergedOptions
|
132
|
-
|
133
|
-
#checks if obj is included in arr Array and returns the position or false
|
134
|
-
includeMarkerImage : (arr, obj) ->
|
135
|
-
for object, index in arr
|
136
|
-
return index if object.url == obj
|
137
|
-
return false
|
138
|
-
|
139
|
-
#checks if MarkerImage exists before creating a new one
|
140
|
-
#returns a MarkerImage or false if ever something wrong is passed as argument
|
141
|
-
createOrRetrieveImage : (currentMarkerPicture, markerWidth, markerHeight, imageAnchorPosition) ->
|
142
|
-
return null if (currentMarkerPicture == "" or currentMarkerPicture == null )
|
143
|
-
|
144
|
-
test_image_index = @includeMarkerImage(@markerImages, currentMarkerPicture)
|
145
|
-
switch test_image_index
|
146
|
-
when false
|
147
|
-
markerImage = @createMarkerImage(currentMarkerPicture, @createSize(markerWidth, markerHeight), null, imageAnchorPosition, null )
|
148
|
-
@markerImages.push(markerImage)
|
149
|
-
return markerImage
|
150
|
-
break
|
151
|
-
else
|
152
|
-
return @markerImages[test_image_index] if typeof test_image_index == 'number'
|
153
|
-
return false
|
154
|
-
|
155
|
-
#clear markers
|
156
|
-
clearMarkers : ->
|
157
|
-
for marker in @markers
|
158
|
-
@clearMarker marker
|
159
|
-
|
160
|
-
#show and hide markers
|
161
|
-
showMarkers : ->
|
162
|
-
for marker in @markers
|
163
|
-
@showMarker marker
|
164
|
-
|
165
|
-
hideMarkers : ->
|
166
|
-
for marker in @markers
|
167
|
-
@hideMarker marker
|
168
|
-
|
169
|
-
clearMarker : (marker) ->
|
170
|
-
marker.serviceObject.setMap(null)
|
171
|
-
|
172
|
-
showMarker : (marker) ->
|
173
|
-
marker.serviceObject.setVisible(true)
|
174
|
-
|
175
|
-
hideMarker : (marker) ->
|
176
|
-
marker.serviceObject.setVisible(false)
|
177
|
-
|
178
|
-
extendBoundsWithMarkers : ->
|
179
|
-
for marker in @markers
|
180
|
-
@boundsObject.extend(marker.serviceObject.position)
|
181
|
-
|
182
|
-
#////////////////////////////////////////////////////
|
183
|
-
#/////////////////// Clusterer //////////////////////
|
184
|
-
#////////////////////////////////////////////////////
|
185
|
-
|
186
|
-
createClusterer : (markers_array) ->
|
187
|
-
return new MarkerClusterer( @serviceObject, markers_array, { maxZoom: @markers_conf.clusterer_maxZoom, gridSize: @markers_conf.clusterer_gridSize, styles: @customClusterer() })
|
188
|
-
|
189
|
-
clearClusterer : ->
|
190
|
-
@markerClusterer.clearMarkers()
|
191
|
-
|
192
|
-
#creates clusters
|
193
|
-
clusterize : ->
|
194
|
-
if @markers_conf.do_clustering == true
|
195
|
-
#first clear the existing clusterer if any
|
196
|
-
@clearClusterer() if @markerClusterer != null
|
197
|
-
|
198
|
-
markers_array = new Array
|
199
|
-
for marker in @markers
|
200
|
-
markers_array.push(marker.serviceObject)
|
201
|
-
|
202
|
-
@markerClusterer = @createClusterer(markers_array)
|
203
|
-
|
204
|
-
#////////////////////////////////////////////////////
|
205
|
-
#/////////////////// INFO WINDOW ////////////////////
|
206
|
-
#////////////////////////////////////////////////////
|
207
|
-
|
208
|
-
#// creates infowindows
|
209
|
-
createInfoWindow : (marker_container) ->
|
210
|
-
if typeof(@jsTemplate) == "function" or marker_container.description?
|
211
|
-
marker_container.description = @jsTemplate(marker_container) if typeof(@jsTemplate) == "function"
|
212
|
-
if @markers_conf.custom_infowindow_class != null
|
213
|
-
#creating custom infowindow
|
214
|
-
boxText = document.createElement("div")
|
215
|
-
boxText.setAttribute("class", @markers_conf.custom_infowindow_class) #to customize
|
216
|
-
boxText.innerHTML = marker_container.description
|
217
|
-
marker_container.infowindow = new InfoBox(@infobox(boxText))
|
218
|
-
currentMap = this
|
219
|
-
google.maps.event.addListener(marker_container.serviceObject, 'click', @openInfoWindow(currentMap, marker_container.infowindow, marker_container.serviceObject))
|
220
|
-
else
|
221
|
-
#create default infowindow
|
222
|
-
marker_container.infowindow = new google.maps.InfoWindow({content: marker_container.description })
|
223
|
-
#add the listener associated
|
224
|
-
currentMap = this
|
225
|
-
google.maps.event.addListener(marker_container.serviceObject, 'click', @openInfoWindow(currentMap, marker_container.infowindow, marker_container.serviceObject))
|
226
|
-
|
227
|
-
openInfoWindow : (currentMap, infoWindow, marker) ->
|
228
|
-
return ->
|
229
|
-
# Close the latest selected marker before opening the current one.
|
230
|
-
currentMap.visibleInfoWindow.close() if currentMap.visibleInfoWindow != null
|
231
|
-
infoWindow.open(currentMap.serviceObject, marker)
|
232
|
-
currentMap.visibleInfoWindow = infoWindow
|
233
|
-
|
234
|
-
#////////////////////////////////////////////////////
|
235
|
-
#///////////////// KML //////////////////
|
236
|
-
#////////////////////////////////////////////////////
|
237
|
-
|
238
|
-
createKmlLayer : (kml) ->
|
239
|
-
kml_options = kml.options || {}
|
240
|
-
kml_options = @mergeObjectWithDefault(kml_options, @kml_options)
|
241
|
-
kml = new google.maps.KmlLayer( kml.url, kml_options)
|
242
|
-
kml.setMap(@serviceObject)
|
243
|
-
return kml
|
244
|
-
|
245
|
-
#////////////////////////////////////////////////////
|
246
|
-
#/////////////////// POLYLINES //////////////////////
|
247
|
-
#////////////////////////////////////////////////////
|
248
|
-
|
249
|
-
#creates a single polyline, triggered by create_polylines
|
250
|
-
create_polyline : (polyline) ->
|
251
|
-
polyline_coordinates = []
|
252
|
-
|
253
|
-
#2 cases here, either we have a coded array of LatLng or we have an Array of LatLng
|
254
|
-
for element in polyline
|
255
|
-
#if we have a coded array
|
256
|
-
if element.coded_array?
|
257
|
-
decoded_array = new google.maps.geometry.encoding.decodePath(element.coded_array)
|
258
|
-
#loop through every point in the array
|
259
|
-
for point in decoded_array
|
260
|
-
polyline_coordinates.push(point)
|
261
|
-
|
262
|
-
#or we have an array of latlng
|
263
|
-
else
|
264
|
-
#by convention, a single polyline could be customized in the first array or it uses default values
|
265
|
-
if element == polyline[0]
|
266
|
-
strokeColor = element.strokeColor || @polylines_conf.strokeColor
|
267
|
-
strokeOpacity = element.strokeOpacity || @polylines_conf.strokeOpacity
|
268
|
-
strokeWeight = element.strokeWeight || @polylines_conf.strokeWeight
|
269
|
-
clickable = element.clickable || @polylines_conf.clickable
|
270
|
-
zIndex = element.zIndex || @polylines_conf.zIndex
|
271
|
-
|
272
|
-
#add latlng if positions provided
|
273
|
-
if element.lat? && element.lng?
|
274
|
-
latlng = @createLatLng(element.lat, element.lng)
|
275
|
-
polyline_coordinates.push(latlng)
|
276
|
-
|
277
|
-
# Construct the polyline
|
278
|
-
new_poly = new google.maps.Polyline
|
279
|
-
path: polyline_coordinates
|
280
|
-
strokeColor: strokeColor
|
281
|
-
strokeOpacity: strokeOpacity
|
282
|
-
strokeWeight: strokeWeight
|
283
|
-
clickable: clickable
|
284
|
-
zIndex: zIndex
|
285
|
-
|
286
|
-
#save polyline
|
287
|
-
polyline.serviceObject = new_poly
|
288
|
-
new_poly.setMap(@serviceObject)
|
289
|
-
|
290
|
-
|
291
|
-
updateBoundsWithPolylines: ()->
|
292
|
-
for polyline in @polylines
|
293
|
-
polyline_points = polyline.serviceObject.latLngs.getArray()[0].getArray()
|
294
|
-
for point in polyline_points
|
295
|
-
@boundsObject.extend point
|
296
|
-
|
297
|
-
#////////////////////////////////////////////////////
|
298
|
-
#///////////////// KML //////////////////
|
299
|
-
#////////////////////////////////////////////////////
|
300
|
-
|
301
|
-
create_kml : ->
|
302
|
-
for kml in @kml
|
303
|
-
kml.serviceObject = @createKmlLayer kml
|
304
|
-
|
305
|
-
#////////////////////////////////////////////////////
|
306
|
-
#/////////////////// Other methods //////////////////
|
307
|
-
#////////////////////////////////////////////////////
|
308
|
-
|
309
|
-
fitBounds : ->
|
310
|
-
@serviceObject.fitBounds(@boundsObject) unless @boundsObject.isEmpty()
|
311
|
-
|
312
|
-
centerMapOnUser : ->
|
313
|
-
@serviceObject.setCenter(@userLocation)
|
314
|
-
|
315
|
-
updateBoundsWithPolygons: ()->
|
316
|
-
for polygon in @polygons
|
317
|
-
polygon_points = polygon.serviceObject.latLngs.getArray()[0].getArray()
|
318
|
-
for point in polygon_points
|
319
|
-
@boundsObject.extend point
|
320
|
-
|
321
|
-
updateBoundsWithCircles: ()->
|
322
|
-
for circle in @circles
|
323
|
-
@boundsObject.extend(circle.serviceObject.getBounds().getNorthEast())
|
324
|
-
@boundsObject.extend(circle.serviceObject.getBounds().getSouthWest())
|
325
|
-
|
326
|
-
extendMapBounds: ()->
|
327
|
-
for bound in @map_options.bounds
|
328
|
-
#create points from bounds provided
|
329
|
-
@boundsObject.extend @createLatLng(bound.lat, bound.lng)
|
330
|
-
|
331
|
-
adaptMapToBounds:()->
|
332
|
-
#if autozoom is false, take user info into account
|
333
|
-
if !@map_options.auto_zoom
|
334
|
-
map_center = @boundsObject.getCenter()
|
335
|
-
@map_options.center_latitude = map_center.lat()
|
336
|
-
@map_options.center_longitude = map_center.lng()
|
337
|
-
@serviceObject.setCenter(map_center)
|
338
|
-
else
|
339
|
-
@fitBounds()
|