ym4r-mapstraction 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.DS_Store +0 -0
- data/.gitignore +2 -0
- data/LICENSE +20 -0
- data/README.rdoc +158 -0
- data/Rakefile +52 -0
- data/VERSION +1 -0
- data/javascript/clusterer.js +410 -0
- data/javascript/mapquest-js/mqcommon.js +1740 -0
- data/javascript/mapquest-js/mqexec.js +977 -0
- data/javascript/mapquest-js/mqobjects.js +10733 -0
- data/javascript/mapquest-js/mqutils.js +1001 -0
- data/javascript/mapstraction-geocode.js +179 -0
- data/javascript/mapstraction-route.js +200 -0
- data/javascript/mapstraction.js +3570 -0
- data/javascript/ym4r-mapstraction.js +105 -0
- data/lib/mapstraction_plugin/helper.rb +14 -0
- data/lib/mapstraction_plugin/mapping.rb +120 -0
- data/lib/mapstraction_plugin/mapstraction.rb +309 -0
- data/lib/mapstraction_plugin/overlay.rb +105 -0
- data/lib/mapstraction_plugin/routing.rb +56 -0
- data/lib/ym4r_mapstraction.rb +43 -0
- data/tasks/ym4r_mapstraction_tasks.rake +4 -0
- data/test/ym4r_mapstraction_test.rb +8 -0
- data/ym4r-mapstraction.gemspec +69 -0
- metadata +84 -0
@@ -0,0 +1,105 @@
|
|
1
|
+
module Ym4r
|
2
|
+
module MapstractionPlugin
|
3
|
+
#A graphical marker positionned through geographic ccoordinates (in the WGS84 datum). An HTML info window can be set to be displayed when the marker is clicked on. Options are <tt>:info_bubble</tt> (ex: <tt>"Hello"</tt>), <tt>:info_div</tt> (ex: <tt>["Hello","itemContent"]</tt>, the itemContent part indicating the div element where to display the info), <tt>:label</tt> (ex: <tt>"Label"</tt>) and icon (ex: <tt>"/images/icon.png"</tt>).
|
4
|
+
class Marker
|
5
|
+
include MappingObject
|
6
|
+
attr_accessor :point, :options
|
7
|
+
|
8
|
+
def initialize(point, options = {})
|
9
|
+
if point.is_a?(Array)
|
10
|
+
@point = LatLonPoint.new(point)
|
11
|
+
else
|
12
|
+
@point = point
|
13
|
+
end
|
14
|
+
@options = options
|
15
|
+
end
|
16
|
+
|
17
|
+
def create
|
18
|
+
creation = "new Marker(#{MappingObject.javascriptify_variable(@point)})"
|
19
|
+
if !@options.empty?
|
20
|
+
creation = "addDataToMarker(#{creation},#{MappingObject.javascriptify_variable(@options)})"
|
21
|
+
end
|
22
|
+
creation
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
#A basic Latitude/longitude point.
|
27
|
+
class LatLonPoint
|
28
|
+
include MappingObject
|
29
|
+
attr_accessor :lat,:lon
|
30
|
+
|
31
|
+
def initialize(latlon)
|
32
|
+
@lat = latlon[0]
|
33
|
+
@lon = latlon[1]
|
34
|
+
end
|
35
|
+
def create
|
36
|
+
"new LatLonPoint(#{@lat},#{@lon})"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
#Clustering class, to efficiently manage a large number of markers on a map
|
41
|
+
class Clusterer
|
42
|
+
include MappingObject
|
43
|
+
|
44
|
+
attr_accessor :options, :markers
|
45
|
+
|
46
|
+
def initialize(markers = [], options = {})
|
47
|
+
@mapstraction = mapstraction
|
48
|
+
@options = options
|
49
|
+
@markers = markers
|
50
|
+
end
|
51
|
+
|
52
|
+
#To add a marker to the Clusterer before hte mapstraction.clusterer_init is called on the clusterer.
|
53
|
+
#No effect after...
|
54
|
+
def add_marker_init(marker)
|
55
|
+
@markers << marker
|
56
|
+
end
|
57
|
+
|
58
|
+
def create
|
59
|
+
"new Clusterer(#{MappingObject.javascriptify_variable(@markers)},#{MappingObject.javascriptify_variable(@options)})"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
class Polyline
|
64
|
+
include MappingObject
|
65
|
+
attr_accessor :points, :options
|
66
|
+
|
67
|
+
def initialize(points,options = {})
|
68
|
+
@points = points
|
69
|
+
@options = options
|
70
|
+
end
|
71
|
+
|
72
|
+
def create
|
73
|
+
creation = "new Polyline(#{MappingObject.javascriptify_variable(@points)})"
|
74
|
+
if !@options.empty?
|
75
|
+
creation = "addDataToPolyline(#{creation},#{MappingObject.javascriptify_variable(@options)})"
|
76
|
+
end
|
77
|
+
creation
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
#A rectangular bounding box, defined by its south-western and north-eastern corners.
|
82
|
+
class BoundingBox < Struct.new(:swlat,:swlon,:nelat,:nelon)
|
83
|
+
include MappingObject
|
84
|
+
def create
|
85
|
+
"new BoundingBox(#{MappingObject.javascriptify_variable(swlat)},#{MappingObject.javascriptify_variable(swlon)},#{MappingObject.javascriptify_variable(nelat)},#{MappingObject.javascriptify_variable(nelon)})"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
#Represents a group of Markers. The whole group can be shown on and off at once. It should be declared global at initialization time to be useful.
|
90
|
+
class MarkerGroup
|
91
|
+
include MappingObject
|
92
|
+
attr_accessor :active, :markers
|
93
|
+
|
94
|
+
def initialize(markers, active = true )
|
95
|
+
@active = active
|
96
|
+
@markers = markers
|
97
|
+
end
|
98
|
+
|
99
|
+
def create
|
100
|
+
"new MarkerGroup(#{MappingObject.javascriptify_variable(@markers)},#{MappingObject.javascriptify_variable(@active)})"
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Ym4r
|
2
|
+
module MapstractionPlugin
|
3
|
+
class Router
|
4
|
+
include MappingObject
|
5
|
+
|
6
|
+
def initialize(callback, api, error_callback = nil, variable = "router", map = "map")
|
7
|
+
@callback = callback
|
8
|
+
@api = api
|
9
|
+
@error_callback = error_callback
|
10
|
+
@variable = variable
|
11
|
+
@map = map
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_html(options = {})
|
15
|
+
no_load = options[:no_load]
|
16
|
+
no_script_tag = options[:no_script_tag]
|
17
|
+
no_declare = options[:no_declare]
|
18
|
+
no_global = options[:no_global]
|
19
|
+
no_callback = options[:no_callback]
|
20
|
+
no_error_callback = options[:no_error_callback]
|
21
|
+
|
22
|
+
html = ""
|
23
|
+
html << "<script type=\"text/javascript\">\n" if !no_script_tag
|
24
|
+
#put the functions in a separate javascript file to be included in the page
|
25
|
+
html << "var #{@variable};\n" if !no_declare and !no_global
|
26
|
+
html << "window.onload = addCodeToFunction(window.onload,function() {\n" if !no_load
|
27
|
+
|
28
|
+
if !no_declare and no_global
|
29
|
+
html << "#{declare(@variable)}\n"
|
30
|
+
else
|
31
|
+
html << "#{assign_to(@variable)}\n"
|
32
|
+
end
|
33
|
+
|
34
|
+
html << "\n});\n" if !no_load
|
35
|
+
|
36
|
+
if !no_callback
|
37
|
+
html << "function #{@callback}(waypoints, route) {\n"
|
38
|
+
html << "#{@map}.showRoute(route);\n"
|
39
|
+
html << "}\n"
|
40
|
+
end
|
41
|
+
if !no_error_callback
|
42
|
+
html << "function #{@error_callback}() {\n"
|
43
|
+
html << "alert(\"Error calculating route!!!\");\n"
|
44
|
+
html << "}\n"
|
45
|
+
end
|
46
|
+
|
47
|
+
html << "</script>" if !no_script_tag
|
48
|
+
html
|
49
|
+
end
|
50
|
+
|
51
|
+
def create
|
52
|
+
"new MapstractionRouter(#{@callback}, \"#{@api.to_s}\", #{@error_callback})"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'mapstraction_plugin/mapping'
|
2
|
+
require 'mapstraction_plugin/mapstraction'
|
3
|
+
require 'mapstraction_plugin/overlay'
|
4
|
+
require 'mapstraction_plugin/helper'
|
5
|
+
|
6
|
+
module Ym4r
|
7
|
+
module MapstractionPlugin
|
8
|
+
class GMapsAPIKeyConfigFileNotFoundException < StandardError
|
9
|
+
end
|
10
|
+
class Map24APIKeyConfigFileNotFoundException < StandardError
|
11
|
+
end
|
12
|
+
class MapquestAPIKeyConfigFileNotFoundException < StandardError
|
13
|
+
end
|
14
|
+
class MultimapAPIKeyConfigFileNotFoundException < StandardError
|
15
|
+
end
|
16
|
+
|
17
|
+
unless File.exist?(RAILS_ROOT + '/config/gmaps_api_key.yml')
|
18
|
+
raise GMapsAPIKeyConfigFileNotFoundException.new("File RAILS_ROOT/config/gmaps_api_key.yml not found")
|
19
|
+
else
|
20
|
+
GMAPS_API_KEY = YAML.load_file(RAILS_ROOT + '/config/gmaps_api_key.yml')[ENV['RAILS_ENV']]
|
21
|
+
end
|
22
|
+
|
23
|
+
unless File.exist?(RAILS_ROOT + '/config/map24_api_key.yml')
|
24
|
+
raise Map24APIKeyConfigFileNotFoundException.new("File RAILS_ROOT/config/map24_api_key.yml not found")
|
25
|
+
else
|
26
|
+
MAP24_API_KEY = YAML.load_file(RAILS_ROOT + '/config/map24_api_key.yml')[ENV['RAILS_ENV']]
|
27
|
+
end
|
28
|
+
|
29
|
+
unless File.exist?(RAILS_ROOT + '/config/mapquest_api_key.yml')
|
30
|
+
raise MapquestAPIKeyConfigFileNotFoundException.new("File RAILS_ROOT/config/mapquest_api_key.yml not found")
|
31
|
+
else
|
32
|
+
MAPQUEST_API_KEY = YAML.load_file(RAILS_ROOT + '/config/mapquest_api_key.yml')[ENV['RAILS_ENV']]
|
33
|
+
end
|
34
|
+
|
35
|
+
unless File.exist?(RAILS_ROOT + '/config/multimap_api_key.yml')
|
36
|
+
raise MultimapAPIKeyConfigFileNotFoundException.new("File RAILS_ROOT/config/multimap_api_key.yml not found")
|
37
|
+
else
|
38
|
+
MULTIMAP_API_KEY = YAML.load_file(RAILS_ROOT + '/config/multimap_api_key.yml')[ENV['RAILS_ENV']]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
include Ym4r::MapstractionPlugin
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{ym4r-mapstraction}
|
8
|
+
s.version = "0.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Luke van der Hoeven"]
|
12
|
+
s.date = %q{2010-01-20}
|
13
|
+
s.description = %q{This is an updated/gemmed version of the ym4r-mapstraction plugin by nofxx}
|
14
|
+
s.email = %q{hungerandthirst@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".DS_Store",
|
21
|
+
".gitignore",
|
22
|
+
"LICENSE",
|
23
|
+
"README.rdoc",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"gmaps_api_key.yml.sample",
|
27
|
+
"javascript/clusterer.js",
|
28
|
+
"javascript/mapquest-js/mqcommon.js",
|
29
|
+
"javascript/mapquest-js/mqexec.js",
|
30
|
+
"javascript/mapquest-js/mqobjects.js",
|
31
|
+
"javascript/mapquest-js/mqutils.js",
|
32
|
+
"javascript/mapstraction-geocode.js",
|
33
|
+
"javascript/mapstraction-route.js",
|
34
|
+
"javascript/mapstraction.js",
|
35
|
+
"javascript/ym4r-mapstraction.js",
|
36
|
+
"lib/mapstraction_plugin/helper.rb",
|
37
|
+
"lib/mapstraction_plugin/mapping.rb",
|
38
|
+
"lib/mapstraction_plugin/mapstraction.rb",
|
39
|
+
"lib/mapstraction_plugin/overlay.rb",
|
40
|
+
"lib/mapstraction_plugin/routing.rb",
|
41
|
+
"lib/ym4r_mapstraction.rb",
|
42
|
+
"map24_api_key.yml.sample",
|
43
|
+
"mapquest_api_key.yml.sample",
|
44
|
+
"multimap_api_key.yml.sample",
|
45
|
+
"pkg/ym4r-mapstraction-0.0.1.gem",
|
46
|
+
"tasks/ym4r_mapstraction_tasks.rake",
|
47
|
+
"test/ym4r_mapstraction_test.rb",
|
48
|
+
"ym4r-mapstraction.gemspec"
|
49
|
+
]
|
50
|
+
s.homepage = %q{http://github.com/plukevdh/ym4r_mapstraction}
|
51
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
52
|
+
s.require_paths = ["lib"]
|
53
|
+
s.rubygems_version = %q{1.3.5}
|
54
|
+
s.summary = %q{ym4r-mapstraction: Mapstraction library for ruby applications.}
|
55
|
+
s.test_files = [
|
56
|
+
"test/ym4r_mapstraction_test.rb"
|
57
|
+
]
|
58
|
+
|
59
|
+
if s.respond_to? :specification_version then
|
60
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
61
|
+
s.specification_version = 3
|
62
|
+
|
63
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
64
|
+
else
|
65
|
+
end
|
66
|
+
else
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ym4r-mapstraction
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Luke van der Hoeven
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-01-20 00:00:00 -05:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: This is an updated/gemmed version of the ym4r-mapstraction plugin by nofxx
|
17
|
+
email: hungerandthirst@gmail.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- LICENSE
|
24
|
+
- README.rdoc
|
25
|
+
files:
|
26
|
+
- .DS_Store
|
27
|
+
- .gitignore
|
28
|
+
- LICENSE
|
29
|
+
- README.rdoc
|
30
|
+
- Rakefile
|
31
|
+
- VERSION
|
32
|
+
- gmaps_api_key.yml.sample
|
33
|
+
- javascript/clusterer.js
|
34
|
+
- javascript/mapquest-js/mqcommon.js
|
35
|
+
- javascript/mapquest-js/mqexec.js
|
36
|
+
- javascript/mapquest-js/mqobjects.js
|
37
|
+
- javascript/mapquest-js/mqutils.js
|
38
|
+
- javascript/mapstraction-geocode.js
|
39
|
+
- javascript/mapstraction-route.js
|
40
|
+
- javascript/mapstraction.js
|
41
|
+
- javascript/ym4r-mapstraction.js
|
42
|
+
- lib/mapstraction_plugin/helper.rb
|
43
|
+
- lib/mapstraction_plugin/mapping.rb
|
44
|
+
- lib/mapstraction_plugin/mapstraction.rb
|
45
|
+
- lib/mapstraction_plugin/overlay.rb
|
46
|
+
- lib/mapstraction_plugin/routing.rb
|
47
|
+
- lib/ym4r_mapstraction.rb
|
48
|
+
- map24_api_key.yml.sample
|
49
|
+
- mapquest_api_key.yml.sample
|
50
|
+
- multimap_api_key.yml.sample
|
51
|
+
- pkg/ym4r-mapstraction-0.0.1.gem
|
52
|
+
- tasks/ym4r_mapstraction_tasks.rake
|
53
|
+
- test/ym4r_mapstraction_test.rb
|
54
|
+
- ym4r-mapstraction.gemspec
|
55
|
+
has_rdoc: true
|
56
|
+
homepage: http://github.com/plukevdh/ym4r_mapstraction
|
57
|
+
licenses: []
|
58
|
+
|
59
|
+
post_install_message:
|
60
|
+
rdoc_options:
|
61
|
+
- --charset=UTF-8
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: "0"
|
69
|
+
version:
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: "0"
|
75
|
+
version:
|
76
|
+
requirements: []
|
77
|
+
|
78
|
+
rubyforge_project:
|
79
|
+
rubygems_version: 1.3.5
|
80
|
+
signing_key:
|
81
|
+
specification_version: 3
|
82
|
+
summary: "ym4r-mapstraction: Mapstraction library for ruby applications."
|
83
|
+
test_files:
|
84
|
+
- test/ym4r_mapstraction_test.rb
|