ym4r 0.4.1 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README +40 -243
- data/lib/ym4r/google_maps.rb +3 -8
- data/lib/ym4r/google_maps/geocoding.rb +80 -1
- data/lib/ym4r/google_maps/{tiler/image_tiler.rb → image_tiler.rb} +0 -0
- data/lib/ym4r/google_maps/{tiler/wms_tiler.rb → wms_tiler.rb} +0 -0
- data/lib/ym4r/yahoo_maps.rb +0 -1
- data/rakefile.rb +3 -3
- data/test/test_geocoding.rb +4 -4
- data/test/test_gm_geocoding.rb +28 -0
- data/tools/tile_image.rb +2 -1
- data/tools/tile_wms.rb +4 -3
- metadata +9 -28
- data/lib/ym4r/google_maps/control.rb +0 -66
- data/lib/ym4r/google_maps/geocoding/geocoding.rb +0 -80
- data/lib/ym4r/google_maps/helper.rb +0 -22
- data/lib/ym4r/google_maps/javascript/clusterer.js +0 -444
- data/lib/ym4r/google_maps/javascript/geoRssOverlay.js +0 -107
- data/lib/ym4r/google_maps/javascript/markerGroup.js +0 -104
- data/lib/ym4r/google_maps/javascript/wms-gs.js +0 -69
- data/lib/ym4r/google_maps/layer.rb +0 -115
- data/lib/ym4r/google_maps/map.rb +0 -158
- data/lib/ym4r/google_maps/mapping.rb +0 -126
- data/lib/ym4r/google_maps/overlay.rb +0 -187
- data/lib/ym4r/google_maps/point.rb +0 -36
- data/lib/ym4r/yahoo_maps/flash.rb +0 -7
- data/lib/ym4r/yahoo_maps/flash/latlon.rb +0 -18
- data/lib/ym4r/yahoo_maps/flash/map.rb +0 -74
- data/lib/ym4r/yahoo_maps/flash/mapping.rb +0 -71
- data/lib/ym4r/yahoo_maps/flash/marker.rb +0 -43
- data/lib/ym4r/yahoo_maps/flash/overlay.rb +0 -44
- data/lib/ym4r/yahoo_maps/flash/tool.rb +0 -30
- data/lib/ym4r/yahoo_maps/flash/widget.rb +0 -33
- data/test/test_google_maps.rb +0 -75
@@ -1,71 +0,0 @@
|
|
1
|
-
module Ym4r
|
2
|
-
module YahooMaps
|
3
|
-
module Flash
|
4
|
-
|
5
|
-
module MappingObject
|
6
|
-
attr_reader :variable
|
7
|
-
|
8
|
-
#special method for add_event_listener since the user need to pass reference to methods and the general method_missing won't work for that
|
9
|
-
def add_event_listener(event, method, context)
|
10
|
-
"#{to_javascript}.addEventListener(#{event},#{method},#{context});\n"
|
11
|
-
end
|
12
|
-
|
13
|
-
def remove_event_listener(event, method, context)
|
14
|
-
"#{to_javascript}.removeEventListener(#{event},#{method},#{context});\n"
|
15
|
-
end
|
16
|
-
|
17
|
-
#creates javascript code for missing methods
|
18
|
-
def method_missing(name,*args)
|
19
|
-
args.collect! do |arg|
|
20
|
-
if arg.is_a?(MappingObject)
|
21
|
-
arg.to_javascript
|
22
|
-
elsif arg.is_a?(String)
|
23
|
-
"\"#{escape_javascript(arg)}\""
|
24
|
-
else
|
25
|
-
arg.to_s
|
26
|
-
end
|
27
|
-
end
|
28
|
-
"#{to_javascript}.#{javascriptify(name.to_s)}(#{args.join(",")});\n"
|
29
|
-
end
|
30
|
-
|
31
|
-
#lifted from rails
|
32
|
-
def escape_javascript(javascript)
|
33
|
-
javascript.gsub(/\r\n|\n|\r/, "\\n").gsub(/["']/) { |m| "\\#{m}" }
|
34
|
-
end
|
35
|
-
|
36
|
-
#transform a ruby-type method name (like qsd_fghj) to a Yahoo! Map style one (like qsdFghj)
|
37
|
-
def javascriptify(method_name)
|
38
|
-
method_name.gsub(/_(\w)/){|s| $1.upcase}
|
39
|
-
end
|
40
|
-
|
41
|
-
#Declare Mapping Object (Map, Tool, Marker,...) of name variable
|
42
|
-
def declare(variable)
|
43
|
-
@variable = variable
|
44
|
-
"var #{variable} = #{create};\n"
|
45
|
-
end
|
46
|
-
|
47
|
-
#Returns a Javascript script representing the object
|
48
|
-
def to_javascript
|
49
|
-
unless @variable.nil?
|
50
|
-
@variable
|
51
|
-
else
|
52
|
-
create
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
#Creates a Mapping Object in Javascript
|
57
|
-
#To be implemented by subclasses if needed
|
58
|
-
def create
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
class Variable
|
63
|
-
include MappingObject
|
64
|
-
|
65
|
-
def initialize(variable)
|
66
|
-
@variable = variable
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
module Ym4r
|
2
|
-
module YahooMaps
|
3
|
-
module Flash
|
4
|
-
module Marker
|
5
|
-
EVENT_INITIALIZE = "Marker.EVENT_INITIALIZE"
|
6
|
-
end
|
7
|
-
|
8
|
-
class CustomPOIMarker < Struct.new(:index, :title, :description, :marker_color, :stroke_color)
|
9
|
-
include MappingObject
|
10
|
-
|
11
|
-
def create
|
12
|
-
"new CustomPOIMarker('#{index}','#{title}','#{description}','#{marker_color}','#{stroke_color}')";
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
class CustomImageMarker < Struct.new(:url)
|
17
|
-
include MappingObject
|
18
|
-
|
19
|
-
def create
|
20
|
-
"new CutomImageMarker('#{url}')"
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
class CustomSWFMarker < Struct.new(:url)
|
25
|
-
include MappingObject
|
26
|
-
|
27
|
-
def create
|
28
|
-
"new CustomSWFMarker('#{url}')"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
class WaypointMarker < Struct.new(:index)
|
33
|
-
include MappingObject
|
34
|
-
|
35
|
-
def create
|
36
|
-
"new WaypointMarker('#{index}')"
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
|
@@ -1,44 +0,0 @@
|
|
1
|
-
module Ym4r
|
2
|
-
module YahooMaps
|
3
|
-
module Flash
|
4
|
-
module Overlay
|
5
|
-
EVENT_INITIALIZE = "Overlay.EVENT_INITIALIZE"
|
6
|
-
end
|
7
|
-
|
8
|
-
class CustomSWFOverlay < Struct.new(:url)
|
9
|
-
include MappingObject
|
10
|
-
|
11
|
-
def create
|
12
|
-
"new CustomSWFOverlay('#{url}')"
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
class GeoRSSOverlay < Struct.new(:url)
|
17
|
-
include MappingObject
|
18
|
-
|
19
|
-
def create
|
20
|
-
"new GeoRSSOverlay('#{url}')"
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
class LocalSearchOverlay
|
25
|
-
include MappingObject
|
26
|
-
|
27
|
-
EVENT_SEARCH_ERROR = "LocalSearchOverlay.EVENT_SEARCH_ERROR"
|
28
|
-
EVENT_SEARCH_SUCCESS = "LocalSearchOverlay.EVENT_SEARCH_SUCCESS"
|
29
|
-
|
30
|
-
def create
|
31
|
-
"new LocalSearchOverlay()"
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
class TrafficOverlay
|
36
|
-
include MappingObject
|
37
|
-
|
38
|
-
def create
|
39
|
-
"new TrafficOverlay()"
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
module Ym4r
|
2
|
-
module YahooMaps
|
3
|
-
module Flash
|
4
|
-
module Tool
|
5
|
-
EVENT_INITIALIZE = "Tool.EVENT_INITIALIZE"
|
6
|
-
end
|
7
|
-
|
8
|
-
class CustomSWFTool < Struct.new(:url,:icon_url)
|
9
|
-
include MappingObject
|
10
|
-
|
11
|
-
EVENT_LOADED = "CustomSWFTool.EVENT_LOADED"
|
12
|
-
|
13
|
-
def create
|
14
|
-
"new CustomSWFTool('#{url}','#{icon_url}')"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
class PanTool
|
19
|
-
include MappingObject
|
20
|
-
|
21
|
-
EVENT_DRAG_STOP = "PanTool.EVENT_DRAG_STOP"
|
22
|
-
EVENT_DRAG_START = "PanTool.EVENT_DRAG_START"
|
23
|
-
|
24
|
-
def create
|
25
|
-
"new PanTool()"
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
module Ym4r
|
2
|
-
module YahooMaps
|
3
|
-
module Flash
|
4
|
-
module Widget
|
5
|
-
EVENT_INITIALIZE = "Widget.EVENT_INITIALIZE"
|
6
|
-
end
|
7
|
-
|
8
|
-
class NavigatorWidget
|
9
|
-
include MappingObject
|
10
|
-
|
11
|
-
def create
|
12
|
-
"new NavigatorWidget()"
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
class SatelliteControlWidget
|
17
|
-
include MappingObject
|
18
|
-
|
19
|
-
def create
|
20
|
-
"new SatelliteControlWidget()"
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
class ToolBarWidget
|
25
|
-
include MappingObject
|
26
|
-
|
27
|
-
def create
|
28
|
-
"new ToolBarWidget()"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
data/test/test_google_maps.rb
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
2
|
-
|
3
|
-
require 'ym4r/google_maps'
|
4
|
-
require 'ym4r/google_maps/geocoding'
|
5
|
-
require 'test/unit'
|
6
|
-
|
7
|
-
include Ym4r::GoogleMaps
|
8
|
-
|
9
|
-
class TestGoogleMaps< Test::Unit::TestCase
|
10
|
-
def test_javascriptify_method
|
11
|
-
assert_equal("addOverlayToHello",MappingObject::javascriptify_method("add_overlay_to_hello"))
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_javascriptify_variable_mapping_object
|
15
|
-
map = GMap.new("div")
|
16
|
-
assert_equal(map.to_javascript,MappingObject::javascriptify_variable(map))
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_javascriptify_variable_numeric
|
20
|
-
assert_equal("123.4",MappingObject::javascriptify_variable(123.4))
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_javascriptify_variable_array
|
24
|
-
map = GMap.new("div")
|
25
|
-
assert_equal("[123.4,#{map.to_javascript},[123.4,#{map.to_javascript}]]",MappingObject::javascriptify_variable([123.4,map,[123.4,map]]))
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_javascriptify_variable_hash
|
29
|
-
map = GMap.new("div")
|
30
|
-
test_str = MappingObject::javascriptify_variable("hello" => map, "chopotopoto" => [123.55,map])
|
31
|
-
assert("{hello : #{map.to_javascript},chopotopoto : [123.55,#{map.to_javascript}]}" == test_str || "{chopotopoto : [123.55,#{map.to_javascript}],hello : #{map.to_javascript}}" == test_str)
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_method_call_on_mapping_object
|
35
|
-
map = GMap.new("div","map")
|
36
|
-
assert_equal("map.addHello(123.4);",map.add_hello(123.4).to_s)
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_nested_calls_on_mapping_object
|
40
|
-
gmap = GMap.new("div","map")
|
41
|
-
assert_equal("map.addHello(map.hoYoYo(123.4),map);",gmap.add_hello(gmap.ho_yo_yo(123.4),gmap).to_s)
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_declare_variable_latlng
|
45
|
-
point = GLatLng.new([123.4,123.6])
|
46
|
-
assert_equal("var point = new GLatLng(123.4,123.6);",point.declare("point"))
|
47
|
-
assert_equal("point",point.variable)
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_array_indexing
|
51
|
-
obj = Variable.new("obj")
|
52
|
-
assert_equal("obj[0]",obj[0].variable)
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_google_maps_geocoding
|
56
|
-
placemarks = Geocoding.get("Rue Clovis Paris")
|
57
|
-
assert_equal(Geocoding::GEO_SUCCESS,placemarks.status)
|
58
|
-
assert_equal(1,placemarks.length)
|
59
|
-
placemark = placemarks[0]
|
60
|
-
assert_equal("FR",placemark.country_code)
|
61
|
-
assert_equal("Paris",placemark.locality)
|
62
|
-
assert_equal("75005",placemark.postal_code)
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_google_maps_pakistan
|
66
|
-
placemarks = Geocoding.get("Lahore PK")
|
67
|
-
assert_equal(Geocoding::GEO_SUCCESS,placemarks.status)
|
68
|
-
assert_equal(1,placemarks.length)
|
69
|
-
placemark = placemarks[0]
|
70
|
-
assert_equal("PK",placemark.country_code)
|
71
|
-
assert_equal("Lahore",placemark.locality)
|
72
|
-
assert_equal("",placemark.thoroughfare)
|
73
|
-
end
|
74
|
-
|
75
|
-
end
|