gmaps4rails 1.4.8 → 1.5.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +11 -0
- data/.travis.yml +10 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +175 -0
- data/Guardfile +38 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +26 -37
- data/Rakefile +4 -0
- data/app/assets/javascripts/gmaps4rails/gmaps4rails.base.js.coffee +40 -34
- data/app/assets/javascripts/gmaps4rails/gmaps4rails.googlemaps.js.coffee +4 -2
- data/app/views/gmaps4rails/_gmaps4rails.html.erb +13 -12
- data/gmaps4rails.gemspec +38 -0
- data/lib/gmaps4rails.rb +0 -8
- data/lib/gmaps4rails/acts_as_gmappable.rb +55 -33
- data/lib/gmaps4rails/base.rb +7 -12
- data/lib/gmaps4rails/helper/gmaps4rails_helper.rb +16 -42
- data/lib/gmaps4rails/js_builder.rb +121 -0
- data/lib/gmaps4rails/json_builder.rb +127 -0
- data/lib/gmaps4rails/version.rb +3 -0
- data/lib/gmaps4rails/view_helper.rb +171 -0
- data/lib/tasks/gmaps4rails_tasks.rake +4 -0
- data/lib/tasks/jasmine.rake +8 -0
- data/public/javascripts/gmaps4rails/gmaps4rails.base.js +81 -30
- data/public/javascripts/gmaps4rails/gmaps4rails.bing.js +34 -11
- data/public/javascripts/gmaps4rails/gmaps4rails.googlemaps.js +45 -21
- data/public/javascripts/gmaps4rails/gmaps4rails.mapquest.js +33 -14
- data/public/javascripts/gmaps4rails/gmaps4rails.openlayers.js +33 -20
- data/spec/base/base_spec.rb +185 -0
- data/spec/base/geocoding_spec.rb +17 -0
- data/spec/dummy/.gitignore +2 -0
- data/spec/dummy/.rspec +1 -0
- data/spec/dummy/README.rdoc +261 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +15 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/assets/stylesheets/gmaps4rails.css +24 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/controllers/users_controller.rb +96 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.gitkeep +0 -0
- data/spec/dummy/app/models/.gitkeep +0 -0
- data/spec/dummy/app/models/user.rb +9 -0
- data/spec/dummy/app/views/layouts/application.html.erb +16 -0
- data/spec/dummy/app/views/users/_form.html.erb +37 -0
- data/spec/dummy/app/views/users/_my_template.html.erb +2 -0
- data/spec/dummy/app/views/users/_my_template2.html.erb +1 -0
- data/spec/dummy/app/views/users/ajax_data.js.erb +2 -0
- data/spec/dummy/app/views/users/ajax_test.html.erb +22 -0
- data/spec/dummy/app/views/users/edit.html.erb +6 -0
- data/spec/dummy/app/views/users/index.html.erb +238 -0
- data/spec/dummy/app/views/users/new.html.erb +5 -0
- data/spec/dummy/app/views/users/show.html.erb +30 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +62 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +67 -0
- data/spec/dummy/config/environments/test.rb +37 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +60 -0
- data/spec/dummy/db/migrate/20120408170155_create_users.rb +16 -0
- data/spec/dummy/db/schema.rb +29 -0
- data/spec/dummy/lib/assets/.gitkeep +0 -0
- data/spec/dummy/log/.gitkeep +0 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/javascripts/Player.js +22 -0
- data/spec/dummy/public/javascripts/Song.js +7 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/factories/user_factory.rb +23 -0
- data/spec/javascripts/basic_methods_spec.js +103 -0
- data/spec/javascripts/helpers/.gitkeep +0 -0
- data/spec/javascripts/helpers/SpecHelper.js +87 -0
- data/spec/javascripts/map_spec.js +49 -0
- data/spec/javascripts/markers_methods_spec.js +368 -0
- data/spec/javascripts/mocks_spec.js +27 -0
- data/spec/javascripts/support/jasmine.yml +76 -0
- data/spec/javascripts/support/jasmine_config.rb +23 -0
- data/spec/javascripts/support/jasmine_runner.rb +20 -0
- 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/models/user_spec.rb +447 -0
- data/spec/spec_helper.rb +44 -0
- data/spec/support/geocoding.rb +14 -0
- data/spec/support/matchers.rb +43 -0
- metadata +364 -31
- data/LICENSE.txt +0 -21
- data/app/assets/javascripts/gmaps4rails/all_apis.js +0 -5
- data/app/assets/javascripts/gmaps4rails/bing.js +0 -2
- data/app/assets/javascripts/gmaps4rails/googlemaps.js +0 -2
- data/app/assets/javascripts/gmaps4rails/mapquest.js +0 -2
- data/app/assets/javascripts/gmaps4rails/openlayers.js +0 -2
- data/app/views/gmaps4rails/_html.html.erb +0 -12
- data/app/views/gmaps4rails/_scripts.html.erb +0 -37
- data/lib/gmaps4rails/js_handler.rb +0 -112
- data/lib/gmaps4rails/json_handler.rb +0 -116
- data/public/images/marker.png +0 -0
data/spec/dummy/Rakefile
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
3
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
4
|
+
|
5
|
+
require File.expand_path('../config/application', __FILE__)
|
6
|
+
|
7
|
+
Dummy::Application.load_tasks
|
@@ -0,0 +1,15 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// the compiled file.
|
9
|
+
//
|
10
|
+
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
11
|
+
// GO AFTER THE REQUIRES BELOW.
|
12
|
+
//
|
13
|
+
//= require jquery
|
14
|
+
//= require jquery_ujs
|
15
|
+
//#= require_tree .
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
+
*
|
11
|
+
*= require_self
|
12
|
+
*= require_tree .
|
13
|
+
*/
|
@@ -0,0 +1,24 @@
|
|
1
|
+
.map_container {
|
2
|
+
padding: 6px;
|
3
|
+
border-width: 1px;
|
4
|
+
border-style: solid;
|
5
|
+
border-color: #ccc #ccc #999 #ccc;
|
6
|
+
-webkit-box-shadow: rgba(64, 64, 64, 0.5) 0 2px 5px;
|
7
|
+
-moz-box-shadow: rgba(64, 64, 64, 0.5) 0 2px 5px;
|
8
|
+
box-shadow: rgba(64, 64, 64, 0.1) 0 2px 5px;
|
9
|
+
width: 800px;
|
10
|
+
}
|
11
|
+
|
12
|
+
.gmaps4rails_map {
|
13
|
+
width: 800px;
|
14
|
+
height: 400px;
|
15
|
+
}
|
16
|
+
|
17
|
+
.bing_map {
|
18
|
+
position: absolute;
|
19
|
+
top: 20;
|
20
|
+
left: 10;
|
21
|
+
width: 400px;
|
22
|
+
height: 400px;
|
23
|
+
border:#555555 2px solid;
|
24
|
+
}
|
@@ -0,0 +1,96 @@
|
|
1
|
+
class UsersController < ApplicationController
|
2
|
+
# GET /users
|
3
|
+
# GET /users.json
|
4
|
+
respond_to :html, :json
|
5
|
+
|
6
|
+
|
7
|
+
def index
|
8
|
+
@users = User.all
|
9
|
+
@json = @users.to_gmaps4rails do |user, marker|
|
10
|
+
marker.json({:id => user.id })
|
11
|
+
end
|
12
|
+
respond_with @json
|
13
|
+
end
|
14
|
+
|
15
|
+
def ajax_test
|
16
|
+
end
|
17
|
+
|
18
|
+
def ajax_data
|
19
|
+
@json = User.all.to_gmaps4rails
|
20
|
+
render :json => @json and return
|
21
|
+
end
|
22
|
+
|
23
|
+
def json(string)
|
24
|
+
string
|
25
|
+
end
|
26
|
+
# GET /users/1
|
27
|
+
# GET /users/1.json
|
28
|
+
def show
|
29
|
+
@user = User.find(params[:id])
|
30
|
+
|
31
|
+
respond_to do |format|
|
32
|
+
format.html # show.html.erb
|
33
|
+
format.json { render :json => @user }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# GET /users/new
|
38
|
+
# GET /users/new.json
|
39
|
+
def new
|
40
|
+
@user = User.new
|
41
|
+
|
42
|
+
respond_to do |format|
|
43
|
+
format.html # new.html.erb
|
44
|
+
format.json { render :json => @user }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# GET /users/1/edit
|
49
|
+
def edit
|
50
|
+
@user = User.find(params[:id])
|
51
|
+
end
|
52
|
+
|
53
|
+
# POST /users
|
54
|
+
# POST /users.json
|
55
|
+
def create
|
56
|
+
@user = User.new(params[:user])
|
57
|
+
|
58
|
+
respond_to do |format|
|
59
|
+
if @user.save
|
60
|
+
format.html { redirect_to @user, :notice => 'User was successfully created.' }
|
61
|
+
format.json { render :json => @user, :status => :created, :location => @user }
|
62
|
+
else
|
63
|
+
format.html { render :action => "new" }
|
64
|
+
format.json { render :json => @user.errors, :status => :unprocessable_entity }
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
# PUT /users/1
|
70
|
+
# PUT /users/1.json
|
71
|
+
def update
|
72
|
+
@user = User.find(params[:id])
|
73
|
+
|
74
|
+
respond_to do |format|
|
75
|
+
if @user.update_attributes(params[:user])
|
76
|
+
format.html { redirect_to @user, :notice => 'User was successfully updated.' }
|
77
|
+
format.json { head :ok }
|
78
|
+
else
|
79
|
+
format.html { render :action => "edit" }
|
80
|
+
format.json { render :json => @user.errors, :status => :unprocessable_entity }
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
# DELETE /users/1
|
86
|
+
# DELETE /users/1.json
|
87
|
+
def destroy
|
88
|
+
@user = User.find(params[:id])
|
89
|
+
@user.destroy
|
90
|
+
|
91
|
+
respond_to do |format|
|
92
|
+
format.html { redirect_to users_url }
|
93
|
+
format.json { head :ok }
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
File without changes
|
File without changes
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Dummy</title>
|
5
|
+
<%= stylesheet_link_tag "application", :media => "all" %>
|
6
|
+
<%= javascript_include_tag "application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
<%= yield :head %>
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
|
12
|
+
<%= yield %>
|
13
|
+
|
14
|
+
<%= yield :scripts %>
|
15
|
+
</body>
|
16
|
+
</html>
|
@@ -0,0 +1,37 @@
|
|
1
|
+
<%= form_for(@user) do |f| %>
|
2
|
+
<% if @user.errors.any? %>
|
3
|
+
<div id="error_explanation">
|
4
|
+
<h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2>
|
5
|
+
|
6
|
+
<ul>
|
7
|
+
<% @user.errors.full_messages.each do |msg| %>
|
8
|
+
<li><%= msg %></li>
|
9
|
+
<% end %>
|
10
|
+
</ul>
|
11
|
+
</div>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<div class="field">
|
15
|
+
<%= f.label :name %><br />
|
16
|
+
<%= f.text_field :name %>
|
17
|
+
</div>
|
18
|
+
<div class="field">
|
19
|
+
<%= f.label :address %><br />
|
20
|
+
<%= f.text_field :address %>
|
21
|
+
</div>
|
22
|
+
<div class="field">
|
23
|
+
<%= f.label :latitude %><br />
|
24
|
+
<%= f.text_field :latitude %>
|
25
|
+
</div>
|
26
|
+
<div class="field">
|
27
|
+
<%= f.label :longitude %><br />
|
28
|
+
<%= f.text_field :longitude %>
|
29
|
+
</div>
|
30
|
+
<div class="field">
|
31
|
+
<%= f.label :gmaps %><br />
|
32
|
+
<%= f.check_box :gmaps %>
|
33
|
+
</div>
|
34
|
+
<div class="actions">
|
35
|
+
<%= f.submit %>
|
36
|
+
</div>
|
37
|
+
<% end %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<b>"ok man"</b>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<%= gmaps({:last_map => false}) %>
|
2
|
+
|
3
|
+
|
4
|
+
<button type="button" id="ajax">Replace Markers</button>
|
5
|
+
|
6
|
+
<script type="text/javascript" charset="utf-8">
|
7
|
+
$(function() {
|
8
|
+
|
9
|
+
$(".map_container").hide();
|
10
|
+
|
11
|
+
|
12
|
+
$("#ajax").click(function(){
|
13
|
+
$.getJSON('/users', function(response){
|
14
|
+
$(".map_container").show();
|
15
|
+
Gmaps.map.initialize();
|
16
|
+
Gmaps.map.addMarkers(response);
|
17
|
+
})
|
18
|
+
|
19
|
+
})
|
20
|
+
});</script>
|
21
|
+
|
22
|
+
<!-- -->
|
@@ -0,0 +1,238 @@
|
|
1
|
+
<h1>Listing users</h1>
|
2
|
+
|
3
|
+
<table>
|
4
|
+
<tr>
|
5
|
+
<th>Name</th>
|
6
|
+
<th>Address</th>
|
7
|
+
<th>Latitude</th>
|
8
|
+
<th>Longitude</th>
|
9
|
+
<th>Gmaps</th>
|
10
|
+
<th></th>
|
11
|
+
<th></th>
|
12
|
+
<th></th>
|
13
|
+
</tr>
|
14
|
+
<% @users.each_with_index do |user, index| %>
|
15
|
+
<% break if index == 5 %>
|
16
|
+
<tr>
|
17
|
+
<td><%= user.name %></td>
|
18
|
+
<td><%= user.address %></td>
|
19
|
+
<td><%= user.latitude %></td>
|
20
|
+
<td><%= user.longitude %></td>
|
21
|
+
<td><%= user.gmaps %></td>
|
22
|
+
<td><%= link_to 'Show', user %></td>
|
23
|
+
<td><%= link_to 'Edit', edit_user_path(user) %></td>
|
24
|
+
<td><%= link_to 'Destroy', user, :confirm => 'Are you sure?', :method => :delete %></td>
|
25
|
+
</tr>
|
26
|
+
<% end %>
|
27
|
+
</table>
|
28
|
+
|
29
|
+
<br />
|
30
|
+
|
31
|
+
<!-- <div class="map_container">
|
32
|
+
<div id="map" class="gmaps4rails_map"></div>
|
33
|
+
</div> -->
|
34
|
+
<script type="text/javascript" charset="utf-8">
|
35
|
+
window.onload =alert('ok');
|
36
|
+
|
37
|
+
//
|
38
|
+
// Gmaps.map = new Gmaps4RailsGoogle();
|
39
|
+
// function load_map() {
|
40
|
+
// Gmaps.map.initialize();
|
41
|
+
// Gmaps.map.callback();
|
42
|
+
// };
|
43
|
+
// window.onload = function() { Gmaps.loadMaps(); };
|
44
|
+
//
|
45
|
+
//Gmaps.map.map_options.class = 'gmaps4railsmap';
|
46
|
+
</script>
|
47
|
+
|
48
|
+
|
49
|
+
<%= link_to 'New User', new_user_path %>
|
50
|
+
|
51
|
+
<%#= gmaps({"markers" => {"data" => @json },
|
52
|
+
"map_options" => { :provider => "openlayers"}}) %>
|
53
|
+
<%#= gmaps({}) %>
|
54
|
+
|
55
|
+
|
56
|
+
<%#= gmaps({
|
57
|
+
:map_options => {
|
58
|
+
# :auto_adjust => false,
|
59
|
+
:center_on_user => true,
|
60
|
+
:zoom => 3,
|
61
|
+
:raw => '{ scrollwheel: false }',
|
62
|
+
:center_latitude => 41.574361,
|
63
|
+
:center_longitude => -72.949219,
|
64
|
+
:libraries => ["places"] }
|
65
|
+
}) %>
|
66
|
+
<%#= gmaps( :map_options => {:auto_adjust=>true, :auto_zoom=>true}, :markers => {:data=>"[{\"lat\":43.5368851,\"lng\":-79.6849913}]"}, :circles => {:data=>"[{\"lng\":-79.6849913,\"lat\":43.5368851,\"radius\":5000.0,\"strokeColor\":\"#DD3300\"}]", :options=>{:fillOpacity=>0.35}} )
|
67
|
+
%>
|
68
|
+
<%= gmaps4rails(@json) %>
|
69
|
+
<%#= gmaps(:markers => {:data => @json}, :map_options => { :detect_location => true, :auto_zoom => false, :zoom => 15, :auto_adjust => true, :center_on_user => true}) %>
|
70
|
+
<%#= gmaps(:map_options => { :auto_adjust => true },
|
71
|
+
:markers => {
|
72
|
+
:data => @json,
|
73
|
+
#:options => {:do_clustering => true}
|
74
|
+
}) %>
|
75
|
+
|
76
|
+
<%#= gmaps( {:map_options => { :disableDefaultUI => true, :auto_adjust => true, :center_on_user => true, :detect_location => true, :center_latitude => 41.574361,
|
77
|
+
:center_longitude => -72.949219 }}) %>
|
78
|
+
<%#= gmaps(:markers => {:data => @json, :options => {:do_clustering => false, "custom_infowindow_class" => "yellow", :raw => "{ flat: true, draggable: true}" } },
|
79
|
+
:polygons => {:data => '[[
|
80
|
+
{"lng": 5.190262, "lat": 25.774252},
|
81
|
+
{"lng": 7.118292, "lat": 45.466465},
|
82
|
+
{"lng": 4.75737, "lat": 53.321384}
|
83
|
+
]]'},
|
84
|
+
"circles" => { "data" => '[
|
85
|
+
{"lng": -122.214897, "lat": 37.772323, "radius": 1000000},
|
86
|
+
{"lng": 122.214897, "lat": 37.772323, "radius": 1000000, "strokeColor": "#FF0000"}
|
87
|
+
]'},
|
88
|
+
"polylines" => { "data" => '[[
|
89
|
+
{"lng": -122.214897, "lat": 37.772323},
|
90
|
+
{"lng": -157.821856, "lat": 21.291982},
|
91
|
+
{"lng": 178.431, "lat": -18.142599},
|
92
|
+
{"lng": 153.027892, "lat": -27.46758}
|
93
|
+
],
|
94
|
+
[
|
95
|
+
{"lng": -120.214897, "lat": 30.772323, "strokeColor": "#000", "strokeWeight" : 2 },
|
96
|
+
{"lng": -10.821856, "lat": 50.291982}
|
97
|
+
]]' },
|
98
|
+
:map_options => {:auto_adjust => true, :auto_zoom => false, :zoom => 3, :center_on_user => false, :detect_location => false, :raw => "{styles: pinkParksStyles}" },
|
99
|
+
:last_map => true) %>
|
100
|
+
<%#= gmaps(:markers => {:data => '[{ "lng": "5.9311119", "lat": "43.1251606"} ,{ "lng": "2.3509871", "lat": "48.8566667" },{ "lng": "0", "lat": "0" } ]', "options" => {"do_clustering" => true, "draggable" => true } },
|
101
|
+
:map_options => { :auto_adjust => true, :center_on_user => true, :zoom => 5, :id => "ed" },
|
102
|
+
:scripts => "api",
|
103
|
+
:last_map => false ) %>
|
104
|
+
<%#= gmaps(:markers => {:data => @json, :options => {:do_clustering => false, :draggable => true } },
|
105
|
+
:map_options => { :auto_adjust => true, :center_on_user => true, :zoom => 5, :provider => "openlayers", :id => "joe" },
|
106
|
+
:scripts => "api",
|
107
|
+
:last_map => false ) %>
|
108
|
+
<%#= gmaps(:markers => {:data => @json, :options => {:do_clustering => false, :draggable => true } },
|
109
|
+
:map_options => { :auto_adjust => true, :center_on_user => true, :zoom => 5, :id => "joe3", :provider => "mapquest", :provider_key => MAPQUEST_KEY },
|
110
|
+
:scripts => "api",
|
111
|
+
:last_map => false ) %>
|
112
|
+
<%#= gmaps(:markers => {"data" => @json, :options => {:do_clustering => false, :draggable => true } },
|
113
|
+
:map_options => { :auto_adjust => true, :center_on_user => true, :zoom => 5, :id => "joe2", :provider => "bing", :provider_key => BING_KEY },
|
114
|
+
:scripts => "api" ) %>
|
115
|
+
<%#= gmaps({
|
116
|
+
"map_options" => { "auto_adjust" => false, "zoom" => 0, "libraries" => ["places"] },
|
117
|
+
"markers" => { "data" => @json }
|
118
|
+
}, true, true) %>
|
119
|
+
<%# @circles_json = '[ {"lng": -122.214897, "lat": 37.772323, "radius": 1000000} ]' %>
|
120
|
+
<%#= gmaps(
|
121
|
+
"circles" => { "data" => @circles_json } , "map_options" => { "auto_adjust" => true }
|
122
|
+
) %>
|
123
|
+
<button type="button" onclick="Gmaps.map.replaceMarkers(builder2)">Replace Markers</button>
|
124
|
+
<button type="button" onclick="Gmaps.map.addMarkers(builder2)">Add Markers</button>
|
125
|
+
<button type="button" onclick="Gmaps.map.addMarkers(builder3)">Add Markers bis</button>
|
126
|
+
|
127
|
+
<% content_for :scripts do -%>
|
128
|
+
<script type="text/javascript" charset="utf-8">
|
129
|
+
|
130
|
+
// Gmaps.map.jsTemplate = function(marker_container){
|
131
|
+
// return "ok";
|
132
|
+
// }
|
133
|
+
// function HomeControl(controlDiv, map) {
|
134
|
+
// var chicago = new google.maps.LatLng(41.850033, -87.6500523);
|
135
|
+
//
|
136
|
+
// // Set CSS styles for the DIV containing the control
|
137
|
+
// // Setting padding to 5 px will offset the control
|
138
|
+
// // from the edge of the map.
|
139
|
+
// controlDiv.style.padding = '5px';
|
140
|
+
//
|
141
|
+
// // Set CSS for the control border.
|
142
|
+
// var controlUI = document.createElement('DIV');
|
143
|
+
// controlUI.style.backgroundColor = 'white';
|
144
|
+
// controlUI.style.borderStyle = 'solid';
|
145
|
+
// controlUI.style.borderWidth = '2px';
|
146
|
+
// controlUI.style.cursor = 'pointer';
|
147
|
+
// controlUI.style.textAlign = 'center';
|
148
|
+
// controlUI.title = 'Click to set the map to Home';
|
149
|
+
// controlDiv.appendChild(controlUI);
|
150
|
+
//
|
151
|
+
// // Set CSS for the control interior.
|
152
|
+
// var controlText = document.createElement('DIV');
|
153
|
+
// controlText.style.fontFamily = 'Arial,sans-serif';
|
154
|
+
// controlText.style.fontSize = '12px';
|
155
|
+
// controlText.style.paddingLeft = '4px';
|
156
|
+
// controlText.style.paddingRight = '4px';
|
157
|
+
// controlText.innerHTML = 'Home';
|
158
|
+
// controlUI.appendChild(controlText);
|
159
|
+
//
|
160
|
+
// // Setup the click event listeners: simply set the map to Chicago.
|
161
|
+
// google.maps.event.addDomListener(controlUI, 'click', function() {
|
162
|
+
// map.setCenter(chicago)
|
163
|
+
// });
|
164
|
+
// }
|
165
|
+
//
|
166
|
+
// Gmaps.map.callback = function(){
|
167
|
+
// // Create the DIV to hold the control and call the HomeControl() constructor
|
168
|
+
// // passing in this DIV.
|
169
|
+
// var homeControlDiv = document.createElement('DIV');
|
170
|
+
// var homeControl = new HomeControl(homeControlDiv, Gmaps.map.map);
|
171
|
+
//
|
172
|
+
// homeControlDiv.index = 1;
|
173
|
+
// Gmaps.map.map.controls[google.maps.ControlPosition.TOP_RIGHT].push(homeControlDiv);
|
174
|
+
// };
|
175
|
+
//
|
176
|
+
//
|
177
|
+
// var pinkParksStyles = [
|
178
|
+
// {
|
179
|
+
// featureType: "all",
|
180
|
+
// stylers: [
|
181
|
+
// { saturation: -80 }
|
182
|
+
// ]
|
183
|
+
// },
|
184
|
+
// {
|
185
|
+
// featureType: "poi.park",
|
186
|
+
// stylers: [
|
187
|
+
// { hue: "#ff0023" },
|
188
|
+
// { saturation: 40 }
|
189
|
+
// ]
|
190
|
+
// }
|
191
|
+
// ];
|
192
|
+
//
|
193
|
+
//
|
194
|
+
//
|
195
|
+
// }
|
196
|
+
//
|
197
|
+
// Gmaps.map.infobox = function(boxText) {
|
198
|
+
// return {
|
199
|
+
// content: boxText
|
200
|
+
// ,disableAutoPan: false
|
201
|
+
// ,maxWidth: 0
|
202
|
+
// ,pixelOffset: new google.maps.Size(-140, 0)
|
203
|
+
// ,zIndex: null
|
204
|
+
// ,boxStyle: {
|
205
|
+
// background: "url('http://google-maps-utility-library-v3.googlecode.com/svn/tags/infobox/1.1.5/examples/tipbox.gif') no-repeat"
|
206
|
+
// ,opacity: 0.75
|
207
|
+
// ,width: "280px"
|
208
|
+
// }
|
209
|
+
// ,closeBoxMargin: "10px 2px 2px 2px"
|
210
|
+
// ,closeBoxURL: "http://www.google.com/intl/en_us/mapfiles/close.gif"
|
211
|
+
// ,infoBoxClearance: new google.maps.Size(1, 1)
|
212
|
+
// ,isHidden: false
|
213
|
+
// ,pane: "floatPane"
|
214
|
+
// ,enableEventPropagation: false
|
215
|
+
// }};
|
216
|
+
|
217
|
+
</script>
|
218
|
+
<script type="text/javascript" charset="utf-8">
|
219
|
+
|
220
|
+
var builder2 =
|
221
|
+
[
|
222
|
+
{
|
223
|
+
"lng": "5.9311119",
|
224
|
+
"lat": "42.1251606",
|
225
|
+
} ,{
|
226
|
+
"lng": "32.3509871",
|
227
|
+
"lat": "47.8566667",
|
228
|
+
}
|
229
|
+
];
|
230
|
+
var builder3 = [{
|
231
|
+
"lng": "6.9311119",
|
232
|
+
"lat": "49.1251606",
|
233
|
+
} ,{
|
234
|
+
"lng": "39.3509871",
|
235
|
+
"lat": "40.8566667",
|
236
|
+
} ];
|
237
|
+
</script>
|
238
|
+
<% end -%>
|