travlrmap 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- data/config/travlrmap.yaml.dist +7 -0
- data/lib/travlrmap/sinatra_app.rb +14 -1
- data/lib/travlrmap/version.rb +1 -1
- data/public/images/conv30.png +0 -0
- data/public/images/conv40.png +0 -0
- data/public/images/conv50.png +0 -0
- data/public/images/heart30.png +0 -0
- data/public/images/heart40.png +0 -0
- data/public/images/heart50.png +0 -0
- data/public/images/m1.png +0 -0
- data/public/images/m2.png +0 -0
- data/public/images/m3.png +0 -0
- data/public/images/m4.png +0 -0
- data/public/images/m5.png +0 -0
- data/public/images/people35.png +0 -0
- data/public/images/people45.png +0 -0
- data/public/images/people55.png +0 -0
- data/public/markerclusterer_compiled.js +21 -0
- data/views/_map_js.erb +33 -11
- data/views/layout.erb +1 -0
- metadata +19 -4
data/config/travlrmap.yaml.dist
CHANGED
@@ -10,6 +10,10 @@
|
|
10
10
|
:overview_control: false
|
11
11
|
:pan_control: true
|
12
12
|
:title: My Travels
|
13
|
+
:cluster: true
|
14
|
+
:cluster_grid_size: 40
|
15
|
+
:cluster_minumum_size: 2
|
16
|
+
:cluster_zoom_on_click: true
|
13
17
|
|
14
18
|
:views:
|
15
19
|
:default:
|
@@ -26,7 +30,10 @@
|
|
26
30
|
:types:
|
27
31
|
:visit:
|
28
32
|
:icon: http://your.site/markers/mini-ORANGE-BLANK.png
|
33
|
+
:description: Visit
|
29
34
|
:transit:
|
30
35
|
:icon: http://your.site/markers/mini-BLUE-BLANK.png
|
36
|
+
:description: Transit
|
31
37
|
:lived:
|
32
38
|
:icon: http://your.site/markers/mini-GREEN-BLANK.png
|
39
|
+
:description: Lived
|
@@ -51,6 +51,14 @@ module Travlrmap
|
|
51
51
|
@pan_control = @map[:pan_control].nil? ? true : @map[:pan_control]
|
52
52
|
end
|
53
53
|
|
54
|
+
def to_json
|
55
|
+
@points.sort_by{|p| p[:country]}.map do |point|
|
56
|
+
point[:popup_html] = erb(:"_point_comment", :layout => false, :locals => {:point => point})
|
57
|
+
point[:icon] = @types[ point[:type] ][:icon]
|
58
|
+
point
|
59
|
+
end.to_json
|
60
|
+
end
|
61
|
+
|
54
62
|
def to_kml
|
55
63
|
require 'ruby_kml'
|
56
64
|
|
@@ -99,11 +107,16 @@ module Travlrmap
|
|
99
107
|
erb :index
|
100
108
|
end
|
101
109
|
|
102
|
-
get '/kml' do
|
110
|
+
get '/points/kml' do
|
103
111
|
content_type :"application/vnd.google-earth.kml+xml"
|
104
112
|
to_kml
|
105
113
|
end
|
106
114
|
|
115
|
+
get '/points/json' do
|
116
|
+
content_type :"application/json"
|
117
|
+
to_json
|
118
|
+
end
|
119
|
+
|
107
120
|
get '/images/*' do
|
108
121
|
requested_file = params[:splat].first
|
109
122
|
file = File.expand_path(File.join("images", requested_file), APPROOT)
|
data/lib/travlrmap/version.rb
CHANGED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,21 @@
|
|
1
|
+
(function(){var d=null;function e(a){return function(b){this[a]=b}}function h(a){return function(){return this[a]}}var j;
|
2
|
+
function k(a,b,c){this.extend(k,google.maps.OverlayView);this.c=a;this.a=[];this.f=[];this.ca=[53,56,66,78,90];this.j=[];this.A=!1;c=c||{};this.g=c.gridSize||60;this.l=c.minimumClusterSize||2;this.J=c.maxZoom||d;this.j=c.styles||[];this.X=c.imagePath||this.Q;this.W=c.imageExtension||this.P;this.O=!0;if(c.zoomOnClick!=void 0)this.O=c.zoomOnClick;this.r=!1;if(c.averageCenter!=void 0)this.r=c.averageCenter;l(this);this.setMap(a);this.K=this.c.getZoom();var f=this;google.maps.event.addListener(this.c,
|
3
|
+
"zoom_changed",function(){var a=f.c.getZoom();if(f.K!=a)f.K=a,f.m()});google.maps.event.addListener(this.c,"idle",function(){f.i()});b&&b.length&&this.C(b,!1)}j=k.prototype;j.Q="http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/images/m";j.P="png";j.extend=function(a,b){return function(a){for(var b in a.prototype)this.prototype[b]=a.prototype[b];return this}.apply(a,[b])};j.onAdd=function(){if(!this.A)this.A=!0,n(this)};j.draw=function(){};
|
4
|
+
function l(a){if(!a.j.length)for(var b=0,c;c=a.ca[b];b++)a.j.push({url:a.X+(b+1)+"."+a.W,height:c,width:c})}j.S=function(){for(var a=this.o(),b=new google.maps.LatLngBounds,c=0,f;f=a[c];c++)b.extend(f.getPosition());this.c.fitBounds(b)};j.z=h("j");j.o=h("a");j.V=function(){return this.a.length};j.ba=e("J");j.I=h("J");j.G=function(a,b){for(var c=0,f=a.length,g=f;g!==0;)g=parseInt(g/10,10),c++;c=Math.min(c,b);return{text:f,index:c}};j.$=e("G");j.H=h("G");
|
5
|
+
j.C=function(a,b){for(var c=0,f;f=a[c];c++)q(this,f);b||this.i()};function q(a,b){b.s=!1;b.draggable&&google.maps.event.addListener(b,"dragend",function(){b.s=!1;a.L()});a.a.push(b)}j.q=function(a,b){q(this,a);b||this.i()};function r(a,b){var c=-1;if(a.a.indexOf)c=a.a.indexOf(b);else for(var f=0,g;g=a.a[f];f++)if(g==b){c=f;break}if(c==-1)return!1;b.setMap(d);a.a.splice(c,1);return!0}j.Y=function(a,b){var c=r(this,a);return!b&&c?(this.m(),this.i(),!0):!1};
|
6
|
+
j.Z=function(a,b){for(var c=!1,f=0,g;g=a[f];f++)g=r(this,g),c=c||g;if(!b&&c)return this.m(),this.i(),!0};j.U=function(){return this.f.length};j.getMap=h("c");j.setMap=e("c");j.w=h("g");j.aa=e("g");
|
7
|
+
j.v=function(a){var b=this.getProjection(),c=new google.maps.LatLng(a.getNorthEast().lat(),a.getNorthEast().lng()),f=new google.maps.LatLng(a.getSouthWest().lat(),a.getSouthWest().lng()),c=b.fromLatLngToDivPixel(c);c.x+=this.g;c.y-=this.g;f=b.fromLatLngToDivPixel(f);f.x-=this.g;f.y+=this.g;c=b.fromDivPixelToLatLng(c);b=b.fromDivPixelToLatLng(f);a.extend(c);a.extend(b);return a};j.R=function(){this.m(!0);this.a=[]};
|
8
|
+
j.m=function(a){for(var b=0,c;c=this.f[b];b++)c.remove();for(b=0;c=this.a[b];b++)c.s=!1,a&&c.setMap(d);this.f=[]};j.L=function(){var a=this.f.slice();this.f.length=0;this.m();this.i();window.setTimeout(function(){for(var b=0,c;c=a[b];b++)c.remove()},0)};j.i=function(){n(this)};
|
9
|
+
function n(a){if(a.A)for(var b=a.v(new google.maps.LatLngBounds(a.c.getBounds().getSouthWest(),a.c.getBounds().getNorthEast())),c=0,f;f=a.a[c];c++)if(!f.s&&b.contains(f.getPosition())){for(var g=a,u=4E4,o=d,v=0,m=void 0;m=g.f[v];v++){var i=m.getCenter();if(i){var p=f.getPosition();if(!i||!p)i=0;else var w=(p.lat()-i.lat())*Math.PI/180,x=(p.lng()-i.lng())*Math.PI/180,i=Math.sin(w/2)*Math.sin(w/2)+Math.cos(i.lat()*Math.PI/180)*Math.cos(p.lat()*Math.PI/180)*Math.sin(x/2)*Math.sin(x/2),i=6371*2*Math.atan2(Math.sqrt(i),
|
10
|
+
Math.sqrt(1-i));i<u&&(u=i,o=m)}}o&&o.F.contains(f.getPosition())?o.q(f):(m=new s(g),m.q(f),g.f.push(m))}}function s(a){this.k=a;this.c=a.getMap();this.g=a.w();this.l=a.l;this.r=a.r;this.d=d;this.a=[];this.F=d;this.n=new t(this,a.z(),a.w())}j=s.prototype;
|
11
|
+
j.q=function(a){var b;a:if(this.a.indexOf)b=this.a.indexOf(a)!=-1;else{b=0;for(var c;c=this.a[b];b++)if(c==a){b=!0;break a}b=!1}if(b)return!1;if(this.d){if(this.r)c=this.a.length+1,b=(this.d.lat()*(c-1)+a.getPosition().lat())/c,c=(this.d.lng()*(c-1)+a.getPosition().lng())/c,this.d=new google.maps.LatLng(b,c),y(this)}else this.d=a.getPosition(),y(this);a.s=!0;this.a.push(a);b=this.a.length;b<this.l&&a.getMap()!=this.c&&a.setMap(this.c);if(b==this.l)for(c=0;c<b;c++)this.a[c].setMap(d);b>=this.l&&a.setMap(d);
|
12
|
+
a=this.c.getZoom();if((b=this.k.I())&&a>b)for(a=0;b=this.a[a];a++)b.setMap(this.c);else if(this.a.length<this.l)z(this.n);else{b=this.k.H()(this.a,this.k.z().length);this.n.setCenter(this.d);a=this.n;a.B=b;a.ga=b.text;a.ea=b.index;if(a.b)a.b.innerHTML=b.text;b=Math.max(0,a.B.index-1);b=Math.min(a.j.length-1,b);b=a.j[b];a.da=b.url;a.h=b.height;a.p=b.width;a.M=b.textColor;a.e=b.anchor;a.N=b.textSize;a.D=b.backgroundPosition;this.n.show()}return!0};
|
13
|
+
j.getBounds=function(){for(var a=new google.maps.LatLngBounds(this.d,this.d),b=this.o(),c=0,f;f=b[c];c++)a.extend(f.getPosition());return a};j.remove=function(){this.n.remove();this.a.length=0;delete this.a};j.T=function(){return this.a.length};j.o=h("a");j.getCenter=h("d");function y(a){a.F=a.k.v(new google.maps.LatLngBounds(a.d,a.d))}j.getMap=h("c");
|
14
|
+
function t(a,b,c){a.k.extend(t,google.maps.OverlayView);this.j=b;this.fa=c||0;this.u=a;this.d=d;this.c=a.getMap();this.B=this.b=d;this.t=!1;this.setMap(this.c)}j=t.prototype;
|
15
|
+
j.onAdd=function(){this.b=document.createElement("DIV");if(this.t)this.b.style.cssText=A(this,B(this,this.d)),this.b.innerHTML=this.B.text;this.getPanes().overlayMouseTarget.appendChild(this.b);var a=this;google.maps.event.addDomListener(this.b,"click",function(){var b=a.u.k;google.maps.event.trigger(b,"clusterclick",a.u);b.O&&a.c.fitBounds(a.u.getBounds())})};function B(a,b){var c=a.getProjection().fromLatLngToDivPixel(b);c.x-=parseInt(a.p/2,10);c.y-=parseInt(a.h/2,10);return c}
|
16
|
+
j.draw=function(){if(this.t){var a=B(this,this.d);this.b.style.top=a.y+"px";this.b.style.left=a.x+"px"}};function z(a){if(a.b)a.b.style.display="none";a.t=!1}j.show=function(){if(this.b)this.b.style.cssText=A(this,B(this,this.d)),this.b.style.display="";this.t=!0};j.remove=function(){this.setMap(d)};j.onRemove=function(){if(this.b&&this.b.parentNode)z(this),this.b.parentNode.removeChild(this.b),this.b=d};j.setCenter=e("d");
|
17
|
+
function A(a,b){var c=[];c.push("background-image:url("+a.da+");");c.push("background-position:"+(a.D?a.D:"0 0")+";");typeof a.e==="object"?(typeof a.e[0]==="number"&&a.e[0]>0&&a.e[0]<a.h?c.push("height:"+(a.h-a.e[0])+"px; padding-top:"+a.e[0]+"px;"):c.push("height:"+a.h+"px; line-height:"+a.h+"px;"),typeof a.e[1]==="number"&&a.e[1]>0&&a.e[1]<a.p?c.push("width:"+(a.p-a.e[1])+"px; padding-left:"+a.e[1]+"px;"):c.push("width:"+a.p+"px; text-align:center;")):c.push("height:"+a.h+"px; line-height:"+a.h+
|
18
|
+
"px; width:"+a.p+"px; text-align:center;");c.push("cursor:pointer; top:"+b.y+"px; left:"+b.x+"px; color:"+(a.M?a.M:"black")+"; position:absolute; font-size:"+(a.N?a.N:11)+"px; font-family:Arial,sans-serif; font-weight:bold");return c.join("")}window.MarkerClusterer=k;k.prototype.addMarker=k.prototype.q;k.prototype.addMarkers=k.prototype.C;k.prototype.clearMarkers=k.prototype.R;k.prototype.fitMapToMarkers=k.prototype.S;k.prototype.getCalculator=k.prototype.H;k.prototype.getGridSize=k.prototype.w;
|
19
|
+
k.prototype.getExtendedBounds=k.prototype.v;k.prototype.getMap=k.prototype.getMap;k.prototype.getMarkers=k.prototype.o;k.prototype.getMaxZoom=k.prototype.I;k.prototype.getStyles=k.prototype.z;k.prototype.getTotalClusters=k.prototype.U;k.prototype.getTotalMarkers=k.prototype.V;k.prototype.redraw=k.prototype.i;k.prototype.removeMarker=k.prototype.Y;k.prototype.removeMarkers=k.prototype.Z;k.prototype.resetViewport=k.prototype.m;k.prototype.repaint=k.prototype.L;k.prototype.setCalculator=k.prototype.$;
|
20
|
+
k.prototype.setGridSize=k.prototype.aa;k.prototype.setMaxZoom=k.prototype.ba;k.prototype.onAdd=k.prototype.onAdd;k.prototype.draw=k.prototype.draw;s.prototype.getCenter=s.prototype.getCenter;s.prototype.getSize=s.prototype.T;s.prototype.getMarkers=s.prototype.o;t.prototype.onAdd=t.prototype.onAdd;t.prototype.draw=t.prototype.draw;t.prototype.onRemove=t.prototype.onRemove;
|
21
|
+
})();
|
data/views/_map_js.erb
CHANGED
@@ -1,5 +1,25 @@
|
|
1
1
|
<script type="text/javascript">
|
2
2
|
var map;
|
3
|
+
|
4
|
+
function addPoints(data) {
|
5
|
+
var markers_data = [];
|
6
|
+
if (data.length > 0) {
|
7
|
+
for (var i = 0; i < data.length; i++) {
|
8
|
+
markers_data.push({
|
9
|
+
lat: data[i].lat,
|
10
|
+
lng: data[i].lon,
|
11
|
+
title: data[i].title,
|
12
|
+
icon: data[i].icon,
|
13
|
+
infoWindow: {
|
14
|
+
content: data[i].popup_html
|
15
|
+
},
|
16
|
+
});
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
20
|
+
map.addMarkers(markers_data);
|
21
|
+
}
|
22
|
+
|
3
23
|
$(document).ready(function(){
|
4
24
|
infoWindow = new google.maps.InfoWindow({});
|
5
25
|
map = new GMaps({
|
@@ -7,18 +27,20 @@
|
|
7
27
|
zoom: <%= @map_view[:zoom] %>,
|
8
28
|
lat: <%= @map_view[:lat] %>,
|
9
29
|
lng: <%= @map_view[:lon] %>,
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
infoWindow.open(map.map);
|
30
|
+
<% if @map[:cluster] %>
|
31
|
+
markerClusterer: function(map) {
|
32
|
+
options = {
|
33
|
+
gridSize: <%= @map.fetch(:cluster_grid_size, 40) %>,
|
34
|
+
minimumClusterSize: <%= @map.fetch(:cluster_minumum_size, 2) %>,
|
35
|
+
zoomOnClick: <%= @map.fetch(:cluster_zoom_on_click, true) %>
|
36
|
+
};
|
37
|
+
|
38
|
+
return new MarkerClusterer(map, [], options);
|
20
39
|
}
|
21
|
-
|
40
|
+
<% end %>
|
22
41
|
});
|
42
|
+
|
43
|
+
points = $.getJSON("/points/json");
|
44
|
+
points.done(addPoints);
|
23
45
|
});
|
24
46
|
</script>
|
data/views/layout.erb
CHANGED
@@ -16,6 +16,7 @@
|
|
16
16
|
<link rel="stylesheet" href="///maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
|
17
17
|
<link rel="stylesheet" href="/travlrmap.css">
|
18
18
|
<script src="/gmaps.js"></script>
|
19
|
+
<script src="/markerclusterer_compiled.js"></script>
|
19
20
|
|
20
21
|
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
|
21
22
|
<!--[if lt IE 9]>
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: travlrmap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 12
|
10
|
+
version: 0.0.12
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- R.I.Pienaar
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2015-01-
|
18
|
+
date: 2015-01-03 00:00:00 +00:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -137,8 +137,23 @@ files:
|
|
137
137
|
- views/_point_comment.erb
|
138
138
|
- views/_footer.erb
|
139
139
|
- views/_map_js.erb
|
140
|
+
- public/images/conv30.png
|
141
|
+
- public/images/conv50.png
|
142
|
+
- public/images/m1.png
|
143
|
+
- public/images/conv40.png
|
144
|
+
- public/images/people55.png
|
145
|
+
- public/images/people45.png
|
146
|
+
- public/images/heart50.png
|
147
|
+
- public/images/heart40.png
|
148
|
+
- public/images/m4.png
|
149
|
+
- public/images/m5.png
|
150
|
+
- public/images/people35.png
|
151
|
+
- public/images/m3.png
|
152
|
+
- public/images/heart30.png
|
153
|
+
- public/images/m2.png
|
140
154
|
- public/travlrmap.css
|
141
155
|
- public/favicon.ico
|
156
|
+
- public/markerclusterer_compiled.js
|
142
157
|
- public/gmaps.js
|
143
158
|
- public/markers/marker-PURPLE-BLANK.png
|
144
159
|
- public/markers/mini-RED-BLANK.png
|