• R/O
  • SSH
  • HTTPS

tenarai: 提交


Commit MetaInfo

修訂87 (tree)
時間2008-04-23 23:01:18
作者junkikuchi

Log Message

updated.

Change Summary

差異

--- trunk/webapp/Widget/Content/GMap.rb (revision 86)
+++ trunk/webapp/Widget/Content/GMap.rb (revision 87)
@@ -32,6 +32,16 @@
3232 xml.tag('script', 'type' => 'text/javascript') do |js|
3333 js.code <<-END
3434 $(document).ready(function() {
35+ function createMarker(latlng, info) {
36+ var marker = new GMarker(latlng);
37+
38+ GEvent.addListener(marker, 'click', function() {
39+ marker.openInfoWindowHtml(info);
40+ });
41+
42+ return marker;
43+ }
44+
3545 if(GBrowserIsCompatible()) {
3646 var map = new GMap2(document.getElementById('#{html_id}'));
3747 map.addControl(new GLargeMapControl());
@@ -39,10 +49,13 @@
3949 map.addControl(new GMapTypeControl());
4050 map.addControl(new GOverviewMapControl());
4151 map.enableScrollWheelZoom();
52+
53+ var bound = new GLatLngBounds();
4254 END
4355
44- first = resource.content.trackpoint.first
45- last = resource.content.trackpoint.last
56+ resource.content.traverse do |content|
57+ first = content.trackpoint.first
58+ last = content.trackpoint.last
4659
4760 unless last.nil? || first.nil?
4861 js.code <<-END
@@ -49,10 +62,8 @@
4962 var first = new GLatLng(#{first.lat}, #{first.lng});
5063 var last = new GLatLng(#{last.lat}, #{last.lng});
5164
52- var bound = new GLatLngBounds(first, last);
53- if(!bound.isFullLat() || !bound.isFullLng()) {
54- bound = new GLatLngBounds(last, first);
55- }
65+ bound.extend(first);
66+ bound.extend(last);
5667
5768 map.setCenter(bound.getCenter(), map.getBoundsZoomLevel(bound));
5869 END
@@ -60,25 +71,19 @@
6071
6172 if first
6273 js.code <<-END
63- var first_marker = new GMarker(first);
64- map.addOverlay(first_marker);
65- GEvent.addListener(first_marker, 'click', function() {
66- first_marker.openInfoWindowHtml(
67- '出発地点<br />#{first.date.strftime("%Y年%m月%d日 %H:%M:%S")}'
68- );
69- });
74+ var marker = createMarker(
75+ first, '出発地点<br />#{first.date.strftime("%Y年%m月%d日 %H:%M:%S")}'
76+ );
77+ map.addOverlay(marker);
7078 END
7179 end
7280
7381 if last
7482 js.code <<-END
75- var last_marker = new GMarker(last);
76- map.addOverlay(last_marker);
77- GEvent.addListener(last_marker, 'click', function() {
78- last_marker.openInfoWindowHtml(
79- '到着地点<br />#{last.date.strftime("%Y年%m月%d日 %H:%M:%S")}'
80- );
81- });
83+ var marker = createMarker(
84+ last, '到着地点<br />#{last.date.strftime("%Y年%m月%d日 %H:%M:%S")}'
85+ );
86+ map.addOverlay(marker);
8287 END
8388 else
8489 js.code <<-END
@@ -86,7 +91,7 @@
8691 END
8792 end
8893
89- resource.content.tracklog.each do |log|
94+ content.tracklog.each do |log|
9095 js.code <<-END
9196 var polyline = new GPolyline.fromEncoded({
9297 opacity: 0.6,
@@ -98,6 +103,7 @@
98103 map.addOverlay(polyline);
99104 END
100105 end
106+ end
101107
102108 js.code <<-END
103109 }
--- trunk/webapp/Content.rb (revision 86)
+++ trunk/webapp/Content.rb (revision 87)
@@ -10,7 +10,8 @@
1010 class TrackPoint < Tenarai::DB::Reference::Multiple
1111 def first
1212 @link.dst_table.query(
13- 'WHERE %s ORDER BY date LIMIT 1' % @link.dst_col
13+ 'WHERE %s = ? ORDER BY date LIMIT 1' % @link.dst_col,
14+ @row.id
1415 ) do |row|
1516 return row
1617 end
@@ -18,7 +19,8 @@
1819
1920 def last
2021 @link.dst_table.query(
21- 'WHERE %s ORDER BY date DESC LIMIT 1' % @link.dst_col
22+ 'WHERE %s = ? ORDER BY date DESC LIMIT 1' % @link.dst_col,
23+ @row.id
2224 ) do |row|
2325 return row
2426 end
Show on old repository browser