gmaps4rails 1.5.8 → 2.0.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +12 -0
- data/.travis.yml +9 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +149 -0
- data/Guardfile.old +24 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +129 -0
- data/Rakefile +4 -0
- data/app/views/gmaps4rails/_gmaps4rails.html.erb +20 -0
- data/gmaps4rails.gemspec +38 -0
- data/lib/generators/gmaps4rails/install_generator.rb +43 -0
- data/lib/generators/templates/README +2 -0
- data/lib/gmaps4rails.rb +26 -0
- data/lib/gmaps4rails/acts_as_gmappable.rb +54 -0
- data/lib/gmaps4rails/api_wrappers/base_net_methods.rb +40 -0
- data/lib/gmaps4rails/api_wrappers/direction.rb +87 -0
- data/lib/gmaps4rails/api_wrappers/geocoder.rb +54 -0
- data/lib/gmaps4rails/api_wrappers/places.rb +74 -0
- data/lib/gmaps4rails/base.rb +126 -0
- data/lib/gmaps4rails/extensions/enumerable.rb +14 -0
- data/lib/gmaps4rails/extensions/hash.rb +9 -0
- data/lib/gmaps4rails/helper/gmaps4rails_helper.rb +33 -0
- data/lib/gmaps4rails/js_builder.rb +154 -0
- data/lib/gmaps4rails/json_builder.rb +140 -0
- data/lib/gmaps4rails/model_handler.rb +101 -0
- data/lib/gmaps4rails/version.rb +3 -0
- data/lib/gmaps4rails/view_helper.rb +172 -0
- data/lib/tasks/jasmine.rake +8 -0
- data/public/javascripts/gmaps4rails/all.js +2144 -0
- data/public/javascripts/gmaps4rails/base.js +792 -0
- data/public/javascripts/gmaps4rails/google.js +556 -0
- data/public/javascripts/gmaps4rails/openlayers.js +377 -0
- data/public/stylesheets/gmaps4rails.css +24 -0
- data/spec/dummy/.gitignore +3 -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 +18 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -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 +105 -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/place.rb +16 -0
- data/spec/dummy/app/models/user.rb +12 -0
- data/spec/dummy/app/views/layouts/application.html.erb +17 -0
- data/spec/dummy/app/views/users/_form.html.erb +37 -0
- data/spec/dummy/app/views/users/edit.html.erb +6 -0
- data/spec/dummy/app/views/users/index.html.erb +268 -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/gmaps4rails.rb +1 -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/public/logo.png +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/factories/place_factory.rb +16 -0
- data/spec/factories/user_factory.rb +23 -0
- data/spec/fixtures/google_direction_valid.json +65 -0
- data/spec/fixtures/google_geocoding_toulon_france.json +58 -0
- data/spec/fixtures/google_places_valid.json +45 -0
- data/spec/fixtures/google_wrong_geocoding.json +4 -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/lib/base_spec.rb +59 -0
- data/spec/lib/direction_spec.rb +53 -0
- data/spec/lib/geocoder_spec.rb +46 -0
- data/spec/lib/js_builder_spec.rb +134 -0
- data/spec/lib/json_builder_spec.rb +232 -0
- data/spec/lib/places_spec.rb +25 -0
- data/spec/models/place_spec.rb +39 -0
- data/spec/models/user_spec.rb +187 -0
- data/spec/spec_helper.rb +38 -0
- data/spec/support/geocoding.rb +40 -0
- data/spec/support/matchers.rb +73 -0
- data/todo +0 -0
- data/vendor/assets/javascripts/gmaps4rails/all.js +1 -0
- data/vendor/assets/javascripts/gmaps4rails/base.coffee +1 -0
- data/vendor/assets/javascripts/gmaps4rails/base/common.coffee +43 -0
- data/vendor/assets/javascripts/gmaps4rails/base/configuration.coffee +7 -0
- data/vendor/assets/javascripts/gmaps4rails/base/gmaps.coffee +13 -0
- data/vendor/assets/javascripts/gmaps4rails/base/interfaces/basic_interface.coffee +15 -0
- data/vendor/assets/javascripts/gmaps4rails/base/interfaces/controller_interface.coffee +15 -0
- data/vendor/assets/javascripts/gmaps4rails/base/interfaces/map_interface.coffee +27 -0
- data/vendor/assets/javascripts/gmaps4rails/base/interfaces/marker_interface.coffee +15 -0
- data/vendor/assets/javascripts/gmaps4rails/base/main.coffee +124 -0
- data/vendor/assets/javascripts/gmaps4rails/base/main_controller_extensions/circle_controller.coffee +29 -0
- data/vendor/assets/javascripts/gmaps4rails/base/main_controller_extensions/kml_controller.coffee +5 -0
- data/vendor/assets/javascripts/gmaps4rails/base/main_controller_extensions/marker_controller.coffee +76 -0
- data/vendor/assets/javascripts/gmaps4rails/base/main_controller_extensions/polygon_controller.coffee +29 -0
- data/vendor/assets/javascripts/gmaps4rails/base/main_controller_extensions/polyline_controller.coffee +29 -0
- data/vendor/assets/javascripts/gmaps4rails/base/objects/circle.coffee +12 -0
- data/vendor/assets/javascripts/gmaps4rails/base/objects/kml.coffee +8 -0
- data/vendor/assets/javascripts/gmaps4rails/base/objects/map.coffee +62 -0
- data/vendor/assets/javascripts/gmaps4rails/base/objects/marker.coffee +24 -0
- data/vendor/assets/javascripts/gmaps4rails/base/objects/polygon.coffee +11 -0
- data/vendor/assets/javascripts/gmaps4rails/base/objects/polyline.coffee +11 -0
- data/vendor/assets/javascripts/gmaps4rails/bing.coffee +1 -0
- data/vendor/assets/javascripts/gmaps4rails/bing/main.coffee +29 -0
- data/vendor/assets/javascripts/gmaps4rails/bing/objects/map.coffee +63 -0
- data/vendor/assets/javascripts/gmaps4rails/bing/objects/marker.coffee +78 -0
- data/vendor/assets/javascripts/gmaps4rails/bing/shared.coffee +20 -0
- data/vendor/assets/javascripts/gmaps4rails/google.coffee +1 -0
- data/vendor/assets/javascripts/gmaps4rails/google/main.coffee +47 -0
- data/vendor/assets/javascripts/gmaps4rails/google/objects/circle.coffee +38 -0
- data/vendor/assets/javascripts/gmaps4rails/google/objects/kml.coffee +16 -0
- data/vendor/assets/javascripts/gmaps4rails/google/objects/map.coffee +71 -0
- data/vendor/assets/javascripts/gmaps4rails/google/objects/marker.coffee +114 -0
- data/vendor/assets/javascripts/gmaps4rails/google/objects/polygon.coffee +38 -0
- data/vendor/assets/javascripts/gmaps4rails/google/objects/polyline.coffee +49 -0
- data/vendor/assets/javascripts/gmaps4rails/google/shared.coffee +27 -0
- data/vendor/assets/javascripts/gmaps4rails/openlayers.coffee +1 -0
- data/vendor/assets/javascripts/gmaps4rails/openlayers/main.coffee +138 -0
- data/vendor/assets/javascripts/gmaps4rails/openlayers/objects/map.coffee +49 -0
- data/vendor/assets/javascripts/gmaps4rails/openlayers/objects/marker.coffee +68 -0
- data/vendor/assets/javascripts/gmaps4rails/openlayers/objects/polyline.coffee +39 -0
- data/vendor/assets/javascripts/gmaps4rails/openlayers/shared.coffee +19 -0
- metadata +378 -14
- checksums.yaml +0 -7
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,18 @@
|
|
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
|
+
//
|
16
|
+
//= require 'gmaps4rails/all'
|
17
|
+
// require 'gmaps4rails/google'
|
18
|
+
// require 'gmaps4rails/bing'
|
@@ -0,0 +1,15 @@
|
|
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
|
+
*/
|
14
|
+
|
15
|
+
.yellow { border: 1px solid black; margin-top: 8px; background: yellow; padding: 5px; }
|
@@ -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,105 @@
|
|
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
|
+
# marker.title "titre"
|
12
|
+
# marker.picture({
|
13
|
+
# "picture" => "/logo.png",
|
14
|
+
# "width" => 32,
|
15
|
+
# "height" => 32})
|
16
|
+
# marker.picture({
|
17
|
+
# :rich_marker => "<div class='my-marker'>It works!<img height='30' width='30' src='http://farm4.static.flickr.com/3212/3012579547_097e27ced9_m.jpg'/></div>"
|
18
|
+
# })
|
19
|
+
marker.infowindow user.name
|
20
|
+
end
|
21
|
+
respond_with @json
|
22
|
+
end
|
23
|
+
|
24
|
+
def ajax_test
|
25
|
+
end
|
26
|
+
|
27
|
+
def ajax_data
|
28
|
+
@json = User.all.to_gmaps4rails
|
29
|
+
render :json => @json and return
|
30
|
+
end
|
31
|
+
|
32
|
+
def json(string)
|
33
|
+
string
|
34
|
+
end
|
35
|
+
# GET /users/1
|
36
|
+
# GET /users/1.json
|
37
|
+
def show
|
38
|
+
@user = User.find(params[:id])
|
39
|
+
|
40
|
+
respond_to do |format|
|
41
|
+
format.html # show.html.erb
|
42
|
+
format.json { render :json => @user }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# GET /users/new
|
47
|
+
# GET /users/new.json
|
48
|
+
def new
|
49
|
+
@user = User.new
|
50
|
+
|
51
|
+
respond_to do |format|
|
52
|
+
format.html # new.html.erb
|
53
|
+
format.json { render :json => @user }
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# GET /users/1/edit
|
58
|
+
def edit
|
59
|
+
@user = User.find(params[:id])
|
60
|
+
end
|
61
|
+
|
62
|
+
# POST /users
|
63
|
+
# POST /users.json
|
64
|
+
def create
|
65
|
+
@user = User.new(params[:user])
|
66
|
+
|
67
|
+
respond_to do |format|
|
68
|
+
if @user.save
|
69
|
+
format.html { redirect_to @user, :notice => 'User was successfully created.' }
|
70
|
+
format.json { render :json => @user, :status => :created, :location => @user }
|
71
|
+
else
|
72
|
+
format.html { render :action => "new" }
|
73
|
+
format.json { render :json => @user.errors, :status => :unprocessable_entity }
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
# PUT /users/1
|
79
|
+
# PUT /users/1.json
|
80
|
+
def update
|
81
|
+
@user = User.find(params[:id])
|
82
|
+
|
83
|
+
respond_to do |format|
|
84
|
+
if @user.update_attributes(params[:user])
|
85
|
+
format.html { redirect_to @user, :notice => 'User was successfully updated.' }
|
86
|
+
format.json { head :ok }
|
87
|
+
else
|
88
|
+
format.html { render :action => "edit" }
|
89
|
+
format.json { render :json => @user.errors, :status => :unprocessable_entity }
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
# DELETE /users/1
|
95
|
+
# DELETE /users/1.json
|
96
|
+
def destroy
|
97
|
+
@user = User.find(params[:id])
|
98
|
+
@user.destroy
|
99
|
+
|
100
|
+
respond_to do |format|
|
101
|
+
format.html { redirect_to users_url }
|
102
|
+
format.json { head :ok }
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
File without changes
|
File without changes
|
@@ -0,0 +1,16 @@
|
|
1
|
+
if RUBY_VERSION == "1.9.3"
|
2
|
+
|
3
|
+
require 'mongoid'
|
4
|
+
|
5
|
+
class Place
|
6
|
+
include Mongoid::Document
|
7
|
+
include Gmaps4rails::ActsAsGmappable
|
8
|
+
|
9
|
+
acts_as_gmappable :address => :address, :position => :pos
|
10
|
+
|
11
|
+
field :pos, :type => Array
|
12
|
+
field :address, :type => String
|
13
|
+
field :gmaps, :type => Boolean
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Dummy</title>
|
5
|
+
<%= stylesheet_link_tag "application", :media => "all" %>
|
6
|
+
|
7
|
+
<%= javascript_include_tag "application" %>
|
8
|
+
<%= csrf_meta_tags %>
|
9
|
+
<%= yield :head %>
|
10
|
+
</head>
|
11
|
+
<body>
|
12
|
+
|
13
|
+
<%= yield %>
|
14
|
+
|
15
|
+
<%= yield :scripts %>
|
16
|
+
</body>
|
17
|
+
</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,268 @@
|
|
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, center_on_user: true },
|
71
|
+
:markers => {
|
72
|
+
:data => @json,
|
73
|
+
:options => {:do_clustering => true}
|
74
|
+
}) %>
|
75
|
+
|
76
|
+
<%#= gmaps("markers" => { "data" => @json, "options" => {
|
77
|
+
"picture" => "/logo.png",
|
78
|
+
"width" => 30, "marker_length" => 32 } }) %>
|
79
|
+
|
80
|
+
|
81
|
+
<%#= gmaps( {:map_options => { :disableDefaultUI => true, :auto_adjust => true, :center_on_user => true, :detect_location => true, :center_latitude => 41.574361,
|
82
|
+
:center_longitude => -72.949219 }}) %>
|
83
|
+
<%#= gmaps(:map_options => {:type => "ROADMAP"},
|
84
|
+
:markers => {:data => @json,
|
85
|
+
:options => {"list_container" => "markers_list" }
|
86
|
+
})%>
|
87
|
+
<div id="markers_list"></div>
|
88
|
+
<%#= gmaps(:map_options => { :auto_adjust => true },
|
89
|
+
:markers => { :data => '[{"lat":42.3124,"lng":71.1712}]', :options => {:do_clustering => true} }) %>
|
90
|
+
|
91
|
+
<%= gmaps(
|
92
|
+
:markers => {
|
93
|
+
:data => @json,
|
94
|
+
:options => {
|
95
|
+
:do_clustering => false,
|
96
|
+
# "custom_infowindow_class" => "yellow",
|
97
|
+
:raw => "{ flat: true, draggable: true, animation: google.maps.Animation.BOUNCE}"
|
98
|
+
} },
|
99
|
+
# :polygons => {:data => '[[
|
100
|
+
# {"lng": 5.190262, "lat": 25.774252},
|
101
|
+
# {"lng": 7.118292, "lat": 45.466465},
|
102
|
+
# {"lng": 4.75737, "lat": 53.321384}
|
103
|
+
# ]]'},
|
104
|
+
# :circles => { "data" => '[
|
105
|
+
# {"lng": -122.214897, "lat": 37.772323, "radius": 1000000},
|
106
|
+
# {"lng": 122.214897, "lat": 37.772323, "radius": 1000000, "strokeColor": "#FF0000"}
|
107
|
+
# ]'},
|
108
|
+
:polylines => { "data" => '[[
|
109
|
+
{"lng": -122.214897, "lat": 37.772323},
|
110
|
+
{"lng": -157.821856, "lat": 21.291982},
|
111
|
+
{"lng": 178.431, "lat": -18.142599},
|
112
|
+
{"lng": 153.027892, "lat": -27.46758}
|
113
|
+
],
|
114
|
+
[
|
115
|
+
{"lng": -120.214897, "lat": 30.772323, "strokeColor": "#000", "strokeWeight" : 2 },
|
116
|
+
{"lng": -10.821856, "lat": 50.291982}
|
117
|
+
]]',
|
118
|
+
options: { raw: '{geodesic: true}' }},
|
119
|
+
:kml => { :data => '[{ url: "http://www.searcharoo.net/SearchKml/newyork.kml"},
|
120
|
+
{ url: "http://gmaps-samples.googlecode.com/svn/trunk/ggeoxml/cta.kml",
|
121
|
+
options: {clickable: false } }]' },
|
122
|
+
|
123
|
+
:map_options => {
|
124
|
+
:auto_adjust => true, :zoom => 3, :center_on_user => false, :detect_location => false,
|
125
|
+
# :raw => "{styles: pinkParksStyles}",
|
126
|
+
# :provider => "bing", :provider_key => BING_KEY
|
127
|
+
},
|
128
|
+
:last_map => true) %>
|
129
|
+
<%#= 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 } },
|
130
|
+
:map_options => { :auto_adjust => true, :center_on_user => true, :zoom => 5, :id => "ed" },
|
131
|
+
:scripts => "api",
|
132
|
+
:last_map => false ) %>
|
133
|
+
<%#= gmaps(:markers => {:data => @json, :options => {:do_clustering => false, :draggable => true } },
|
134
|
+
:map_options => { :auto_adjust => true, :center_on_user => true, :zoom => 5, :provider => "openlayers", :id => "joe" },
|
135
|
+
:scripts => "api",
|
136
|
+
:last_map => false)
|
137
|
+
%>
|
138
|
+
<%#= gmaps(:markers => {:data => @json, :options => {:do_clustering => false, :draggable => true } },
|
139
|
+
:map_options => { :auto_adjust => true, :center_on_user => true, :zoom => 5, :id => "joe3", :provider => "mapquest", :provider_key => MAPQUEST_KEY },
|
140
|
+
:scripts => "api",
|
141
|
+
:last_map => false ) %>
|
142
|
+
<%#= gmaps(:markers => {"data" => @json, :options => {:do_clustering => false, :draggable => true } },
|
143
|
+
:map_options => { :auto_adjust => true, :center_on_user => true, :zoom => 5, :id => "joe2", :provider => "bing", :provider_key => BING_KEY },
|
144
|
+
:scripts => "api" ) %>
|
145
|
+
<%#= gmaps({
|
146
|
+
"map_options" => { "auto_adjust" => false, "zoom" => 0, "libraries" => ["places"] },
|
147
|
+
"markers" => { "data" => @json }
|
148
|
+
}, true, true) %>
|
149
|
+
<%# @circles_json = '[ {"lng": -122.214897, "lat": 37.772323, "radius": 1000000} ]' %>
|
150
|
+
<%#= gmaps(
|
151
|
+
"circles" => { "data" => @circles_json } , "map_options" => { "auto_adjust" => true }
|
152
|
+
) %>
|
153
|
+
<button type="button" onclick="Gmaps.map.replaceMarkers(builder2)">Replace Markers</button>
|
154
|
+
<button type="button" onclick="Gmaps.map.addMarkers(builder2)">Add Markers</button>
|
155
|
+
<button type="button" onclick="Gmaps.map.addMarkers(builder3)">Add Markers bis</button>
|
156
|
+
|
157
|
+
<% content_for :scripts do -%>
|
158
|
+
<script type="text/javascript" charset="utf-8">
|
159
|
+
|
160
|
+
// Gmaps.map.jsTemplate = function(marker_container){
|
161
|
+
// return "ok";
|
162
|
+
// }
|
163
|
+
|
164
|
+
// function HomeControl(controlDiv, map) {
|
165
|
+
// var chicago = new google.maps.LatLng(41.850033, -87.6500523);
|
166
|
+
//
|
167
|
+
// // Set CSS styles for the DIV containing the control
|
168
|
+
// // Setting padding to 5 px will offset the control
|
169
|
+
// // from the edge of the map.
|
170
|
+
// controlDiv.style.padding = '5px';
|
171
|
+
//
|
172
|
+
// // Set CSS for the control border.
|
173
|
+
// var controlUI = document.createElement('DIV');
|
174
|
+
// controlUI.style.backgroundColor = 'white';
|
175
|
+
// controlUI.style.borderStyle = 'solid';
|
176
|
+
// controlUI.style.borderWidth = '2px';
|
177
|
+
// controlUI.style.cursor = 'pointer';
|
178
|
+
// controlUI.style.textAlign = 'center';
|
179
|
+
// controlUI.title = 'Click to set the map to Home';
|
180
|
+
// controlDiv.appendChild(controlUI);
|
181
|
+
//
|
182
|
+
// // Set CSS for the control interior.
|
183
|
+
// var controlText = document.createElement('DIV');
|
184
|
+
// controlText.style.fontFamily = 'Arial,sans-serif';
|
185
|
+
// controlText.style.fontSize = '12px';
|
186
|
+
// controlText.style.paddingLeft = '4px';
|
187
|
+
// controlText.style.paddingRight = '4px';
|
188
|
+
// controlText.innerHTML = 'Home';
|
189
|
+
// controlUI.appendChild(controlText);
|
190
|
+
//
|
191
|
+
// // Setup the click event listeners: simply set the map to Chicago.
|
192
|
+
// google.maps.event.addDomListener(controlUI, 'click', function() {
|
193
|
+
// map.setCenter(chicago)
|
194
|
+
// });
|
195
|
+
// }
|
196
|
+
//
|
197
|
+
Gmaps.map.callback = function(){
|
198
|
+
// Create the DIV to hold the control and call the HomeControl() constructor
|
199
|
+
// passing in this DIV.
|
200
|
+
// var homeControlDiv = document.createElement('DIV');
|
201
|
+
// var homeControl = new HomeControl(homeControlDiv, Gmaps.map.map);
|
202
|
+
//
|
203
|
+
// homeControlDiv.index = 1;
|
204
|
+
// Gmaps.map.map.controls[google.maps.ControlPosition.TOP_RIGHT].push(homeControlDiv);
|
205
|
+
//Gmaps.map.serviceObject.setZoom(1);
|
206
|
+
};
|
207
|
+
//
|
208
|
+
//
|
209
|
+
var pinkParksStyles = [
|
210
|
+
{
|
211
|
+
featureType: "all",
|
212
|
+
stylers: [
|
213
|
+
{ saturation: -80 }
|
214
|
+
]
|
215
|
+
},
|
216
|
+
{
|
217
|
+
featureType: "poi.park",
|
218
|
+
stylers: [
|
219
|
+
{ hue: "#ff0023" },
|
220
|
+
{ saturation: 40 }
|
221
|
+
]
|
222
|
+
}
|
223
|
+
];
|
224
|
+
//
|
225
|
+
//
|
226
|
+
|
227
|
+
Gmaps.map.infobox = function(boxText) {
|
228
|
+
return {
|
229
|
+
content: boxText
|
230
|
+
,disableAutoPan: false
|
231
|
+
,maxWidth: 0
|
232
|
+
,pixelOffset: new google.maps.Size(-140, 0)
|
233
|
+
,zIndex: null
|
234
|
+
,boxStyle: {
|
235
|
+
background: "url('http://google-maps-utility-library-v3.googlecode.com/svn/tags/infobox/1.1.5/examples/tipbox.gif') no-repeat"
|
236
|
+
,opacity: 0.75
|
237
|
+
,width: "280px"
|
238
|
+
}
|
239
|
+
,closeBoxMargin: "10px 2px 2px 2px"
|
240
|
+
,closeBoxURL: "http://www.google.com/intl/en_us/mapfiles/close.gif"
|
241
|
+
,infoBoxClearance: new google.maps.Size(1, 1)
|
242
|
+
,isHidden: false
|
243
|
+
,pane: "floatPane"
|
244
|
+
,enableEventPropagation: false
|
245
|
+
}};
|
246
|
+
|
247
|
+
</script>
|
248
|
+
<script type="text/javascript" charset="utf-8">
|
249
|
+
|
250
|
+
var builder2 =
|
251
|
+
[
|
252
|
+
{
|
253
|
+
"lng": "5.9311119",
|
254
|
+
"lat": "42.1251606",
|
255
|
+
} ,{
|
256
|
+
"lng": "32.3509871",
|
257
|
+
"lat": "47.8566667",
|
258
|
+
}
|
259
|
+
];
|
260
|
+
var builder3 = [{
|
261
|
+
"lng": "6.9311119",
|
262
|
+
"lat": "49.1251606",
|
263
|
+
} ,{
|
264
|
+
"lng": "39.3509871",
|
265
|
+
"lat": "40.8566667",
|
266
|
+
} ];
|
267
|
+
</script>
|
268
|
+
<% end -%>
|