Browse files

add trip location map

  • Loading branch information...
1 parent 8fd0315 commit b2e7b0476241c0398a66b68ca7ea6f89f045788d @spang committed Mar 5, 2012
Showing with 39 additions and 0 deletions.
  1. +2 −0 public/javascripts/jquery.ui.map.min.js
  2. +37 −0 views/trip/new.jade
View
2 public/javascripts/jquery.ui.map.min.js
@@ -0,0 +1,2 @@
+/*! http://code.google.com/p/jquery-ui-map/ | Johan Säll Larsson */
+eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1;};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p;}('(3(d){d.a=3(a,b){j c=a.q(".")[0],a=a.q(".")[1];d[c]=d[c]||{};d[c][a]=3(a,b){D.K&&2.P(a,b)};d[c][a].G=d.u({1q:c,1l:a},b);d.1h[a]=3(b){j h="1m"===1o b,i=F.G.18.19(D,1),g=2;k(h&&"1C"===b.1G(0,1))4 g;2.1F(3(){j f=d.M(2,a);f||(f=d.M(2,a,o d[c][a](b,2)));h&&(g=f[b].1i(f,i))});4 g}};d.a("1y.1x",{l:{1w:"1B",1z:5},1A:3(a,b){b&&(2.l[a]=b,2.6("9").R(2.l));4 2.l[a]},P:3(a,b){2.x=b;r.u(2.l,a);2.l.11=2.v(2.l.11);2.T();2.14&&2.14()},T:3(){j a=2;a.n={9:o 7.8.1H(a.x,a.l),I:[],1j:[],N:[],Q:o 7.8.1D};7.8.z.1E(a.n.9,"1n",3(){d(a.x).S("1p",a.n.9)});a.y(a.l.1v,a.n.9)},Y:3(a){2.6("J",o 7.8.1t).u(2.v(a));2.6("9").1r(2.6("J"));4 2},1s:3(a){j b=2.6("9").1u();4 b?b.1T(a.U()):!1},1U:3(a,b){2.6("9").1W[b].W(2.A(a));4 2},1X:3(a,b,c){a.9=2.6("9");a.X=2.v(a.X);j c=o(c||7.8.1V)(a),e=2.6("I");c.L?e[c.L]=c:e.W(c);c.J&&2.Y(c.U());2.y(b,a.9,c);4 d(c)},s:3(a){2.w(2.6(a));2.H(a,[]);4 2},w:3(a){E(j b 12 a)a.13(b)&&(a[b]p 7.8.1f?(7.8.z.22(a[b]),a[b].V&&a[b].V(t)):a[b]p F&&2.w(a[b]),a[b]=t)},1Y:3(a,b,c){j a=2.6(a),e;E(e 12 a)a.13(e)&&c(a[e],b.Z&&a[e][b.B]?-1<d.1L(b.10,a[e][b.B].q(b.Z)):a[e][b.B]===b.10);4 2},6:3(a,b){j c=2.n;k(!c[a]){k(-1<a.1I(">")){E(j e=a.15(/ /g,"").q(">"),d=0;d<e.K;d++){k(!c[e[d]])k(b)c[e[d]]=d+1<e.K?[]:b;1g 4 t;c=c[e[d]]}4 c}b&&!c[a]&&2.H(a,b)}4 c[a]},1N:3(a,b,c){j d=2.6("Q");d.R(a);d.1S(2.6("9"),2.A(b));2.y(c,d);4 2},H:3(a,b){2.n[a]=b;4 2},1O:3(){j a=2.6("9"),b=a.1J();d(a).1k("1K");a.1Z(b);4 2},21:3(){2.s("I");2.s("N");2.s("1j");2.w(2.n);r.1P(2.x,2.1Q)},y:3(a){a&&d.1R(a)&&a.1i(2,F.G.18.19(D,1))},v:3(a){k(!a)4 o 7.8.C(0,0);k(a p 7.8.C)4 a;a=a.15(/ /g,"").q(",");4 o 7.8.C(a[0],a[1])},A:3(a){k(a){k(a p r)4 a[0];k(a p 20)4 a}1g 4 t;4 d("#"+a)[0]}});r.1h.u({1c:3(a,b){4 2.m("1c",a,b)},1d:3(a){4 2.m("1d",a)},1e:3(a,b){4 2.m("1e",a,b)},1b:3(a,b){4 2.m("1b",a,b)},17:3(a,b){4 2.m("17",a,b)},16:3(a){4 2.m("16",a)},1a:3(a){4 2.m("1a",a)},1k:3(a){7.8.z.S(2[0],a)},m:3(a,b,c){7.8&&2[0]p 7.8.1f?7.8.z.1M(2[0],a,b):c?2.O(a,b,c):2.O(a,b);4 2}})})(r);',62,127,'||this|function|return||get|google|maps|map||||||||||var|if|options|addEventListener|instance|new|instanceof|split|jQuery|clear|null|extend|_latLng|_c|el|_call|event|_unwrap|property|LatLng|arguments|for|Array|prototype|set|markers|bounds|length|id|data|services|bind|_setup|iw|setOptions|trigger|_create|getPosition|setMap|push|position|addBounds|delimiter|value|center|in|hasOwnProperty|_init|replace|drag|mouseout|slice|call|dragend|mouseover|click|rightclick|dblclick|MVCObject|else|fn|apply|overlays|triggerEvent|pluginName|string|bounds_changed|typeof|init|namespace|fitBounds|inViewport|LatLngBounds|getBounds|callback|mapTypeId|gmap|ui|zoom|option|roadmap|_|InfoWindow|addListenerOnce|each|substring|Map|indexOf|getCenter|resize|inArray|addListener|openInfoWindow|refresh|removeData|name|isFunction|open|contains|addControl|Marker|controls|addMarker|find|setCenter|Object|destroy|clearInstanceListeners'.split('|'),0,{}))
View
37 views/trip/new.jade
@@ -2,8 +2,10 @@ extends ../layout
block scripts
link(type='text/css', href="/stylesheets/jquery-ui-timepicker-addon.css", rel="stylesheet")
+ script(type='text/javascript', src='http://maps.googleapis.com/maps/api/js?key=AIzaSyD6dqRiTLYdVLFbVy2uVQANM6nUxU5-NSw&sensor=false')
script(type='text/javascript', src='/javascripts/tiny_mce/jquery.tinymce.js')
script(type='text/javascript', src='/javascripts/jquery-ui-timepicker-addon.js')
+ script(type='text/javascript', src='/javascripts/jquery.ui.map.min.js')
script(type='text/javascript')
$(document).ready(function(){
$('#trip_start').datepicker();
@@ -25,7 +27,37 @@ block scripts
theme_advanced_toolbar_location : "bottom",
theme_advanced_resizing : true,
});
+ var mitLatLng = new google.maps.LatLng(42.359057, -71.093571);
+ $('#map_canvas').gmap({
+ 'center' : mitLatLng,
+ 'zoom' : 15,
+ 'mapTypeId' : google.maps.MapTypeId.ROADMAP,
+ });
+ var geocoder = new google.maps.Geocoder();
+ $('#map_canvas_button').click(function() {
+ var address = $('#trip_location').val().replace(/^\s+|\s+$/g, ''); // whitespace trimmed
+ if ( address ) {
+ geocoder.geocode( { 'address': address }, function(results, status) {
+ if (status == google.maps.GeocoderStatus.OK) {
+ $('#map_canvas').gmap('option', 'center', results[0].geometry.location);
+ $('#map_canvas').gmap('addMarker', {
+ 'position': $('#map_canvas').gmap('option', 'center'),
+ bounds: true,
+ });
+ // XXX TODO: remove old marker?
+ } else {
+ alert("Geocode was not successful for the following reason: " + status);
+ }
+ $('#map_canvas').gmap('option', 'zoom', 9);
+ });
+ }
+ });
});
+ style(type="text/css")
+ #map_canvas {
+ width: 600px;
+ height:500px;
+ }
block content
h2 Yeeehaw! We're making a new trip.
@@ -52,6 +84,11 @@ block content
p
textarea.richedit(name='trip_description', id='trip_description', rows='30', cols='80')
p
+ label(for='map_location') trip location (coordinates or name):
+ input(type='text', name='trip_location', id='trip_location', size=10)
+ button#map_canvas_button(type="button") update map
+ div#map_canvas
+ p
label(for='signup_start') sign up open from
input(type='text', name='signup_start', id='signup_start', size='13')
label(for='signup_end') to

0 comments on commit b2e7b04

Please sign in to comment.