From 8209d2dbbec838bf0149695a32f01b99a5141b31 Mon Sep 17 00:00:00 2001 From: jonsowman Date: Thu, 3 Jun 2010 19:49:06 +0100 Subject: [PATCH] Click to set launch location, auto pan to new, new icons --- predict/css/pred.css | 5 ++- predict/images/balloon-sm.png | Bin 0 -> 575 bytes predict/images/marker-sm-black.png | Bin 0 -> 432 bytes predict/images/target-1-sm.png | Bin 0 -> 521 bytes predict/images/target-8-sm.png | Bin 0 -> 557 bytes predict/index.php | 26 ++++++++++-- predict/js/pred.js | 61 +++++++++++++++++++++++++---- 7 files changed, 79 insertions(+), 13 deletions(-) create mode 100644 predict/images/balloon-sm.png create mode 100644 predict/images/marker-sm-black.png create mode 100644 predict/images/target-1-sm.png create mode 100644 predict/images/target-8-sm.png diff --git a/predict/css/pred.css b/predict/css/pred.css index fdd4c9e..2973fce 100644 --- a/predict/css/pred.css +++ b/predict/css/pred.css @@ -11,7 +11,10 @@ body { a { text-decoration: underline; color: #333; cursor: pointer; } /* The whoppping map in the centre */ -#map_canvas { width: 100%; height: 100%; } +#map_canvas { + width: 100%; + height: 100%; +} #status_message{ position: absolute; diff --git a/predict/images/balloon-sm.png b/predict/images/balloon-sm.png new file mode 100644 index 0000000000000000000000000000000000000000..a75e18c3aae0e039231ff0d615ca73e73a682d5b GIT binary patch literal 575 zcmV-F0>J%=P)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2igV$ z5+V-0EYqF<00F;AL_t(2&ux%BXj4%Dg}?Xmqn0-PAt|&4t?r^##7)sj6hw;Hh@*(; zCO9ex1wpWA!Ntv?#e%ES;81Gur-jl;OA|v(j71^7C$(u`l6&*+eb+%7QuM&tzHd0k zVrT3VCr@2HbM{=atE)Ti{3sWvo=-mgl+C30PomeZ-+Y-~$(d|^%@n?t&Cm6USxT>% z^B0Ei{6i-%UwO2g$(z+&$>a*(OmVGjTzA8GUe&yPw-5{t9ykqP|K+vLFb;7-P^{69fUZTJ?K# zgXei4=I7s6j4>#sk+Ojh0x1PbDLP{9#t)oS1`qj8)Lo60UDMeif>Oumrw74iI zCZ3G}gtl)jeJL)qcf^K=hK?k>num}Ar8OJB)_M5g{;g7}nA#x#Dw|oI?MWm?dgAdm z-}l+9RCqEz_IU2i%;+}MDj=nBmp`VbZLDLi<3wLfP2QcGow?V_{08=C;H8r$bPfOj N002ovPDHLkV1n#70=NJG literal 0 HcmV?d00001 diff --git a/predict/images/marker-sm-black.png b/predict/images/marker-sm-black.png new file mode 100644 index 0000000000000000000000000000000000000000..34f4e0e1ebb7eeaa8fd016d94b180c423523d8b1 GIT binary patch literal 432 zcmV;h0Z;ykP)Px#32;bRa{vGf6951U69E94oEQKA00(qQO+^RV1_Kf$5C~#;IsgCw8FWQhbVF}# zZDnqB07G(RVRU6=Aa`kWXdp*PO;A^X4i^9b0Ub$1K~xyijnOg6gD@Dz@wcf%r(|%5 zj?JD$boT&#ryRjU1e^pNdWo(DZ{bp013iLhq`}oCf*lIqxB6V*55MQM@B6lG^E^Ku zkFM+9?>7KQDf2upiXw`lAPB&F-}k*zic*@UDIy|bmSv1FrBvVd-g_8^K`9l-vDVrc zGmhgpj>Z_RbsWb^sbLt-jIrnQSrkRnG=z}P=d-RW=lpiNEz8oj?d5Vg0|2G8EK5Sj z{eG|Ox@}wMT#_W$>-F_|P16Kn7$V{?A%p+`01!g_(uf#_A%O!UQp$OropYRXL=-{@ zArO&s?wqsMN-3eLD#n=B+Iw%UHO3fYthL^Itu>{zs;WZ-|Co%iEX#hFX_`_>|1eKS aZutU1^}sQ9yS48C0000Px#32;bRa{vGf6951U69E94oEQKA00(qQO+^RV1_Kf;H2k<0;{X5wn@L1LR2b6* z!8=GBaU2Km@9%$JPJ)jL5_?INUVPx0=n#v=LN%xr0;1BP2?<#s8JbW1zo-Wz6yqg!9 zjlY-17j~SzudrFduO&<-_Mc6J+P?J%^|3nD-~70&yfNsw(JITHzA893%j~R5vGurb zsNt4C{)klAT4lk)T^MdAqIn?krtn-;i=9XZ6!*i$o;VdPkV&Q zXJ2z=zz+@lzDQTRF(Com6a;=Q1M{D8W1QmZ_afwvZ;2Z<1WtD9iWJK#fq4m1WWwPI z?6WhNriJU{G>S9laJ(J{m_*u0Z(%P5H?hw=(2d*r8raoUp#B%Ib6LJlCCNZOE2%F1 z^P9Khl5tLW{)EM=K60aNxYGhS{4j^i;vb3^@(UD(ERB|^vk_7JrtDDwd0m4ogU#(Y zT_m@$<7C%YfIb3%3dy4kx!z%oc}4}R4&Bo!=WPx#32;bRa{vGf6951U69E94oEQKA00(qQO+^RV1_Kf<3KsNOivR!s8FWQhbVF}# zZDnqB07G(RVRU6=Aa`kWXdp*PO;A^X4i^9b0h&ofK~xyi1;O2KOK}{);m^0{w5Lu> zEE87MRA0s{MbvvGYBZ7tvCM@8HzM&5NW|3=;R08#gu97I<{uD(i$x?7k!;CqONnlr zuHB5CvvxgBSN(Y&0q8Bp(Y0__S0OSa8S|taXqwd-YutWU8|{c&V$@Um^TYtp@}XR; zkQ~{tXH)M#zs4^d*cTkEr`Co$Z=IXqJ=CUi>oy;}o_o17yDOE~j;iw%C~{mfq*Yn3 z_?+mh00000NkvXXu0mjfUKsJF literal 0 HcmV?d00001 diff --git a/predict/index.php b/predict/index.php index 034055c..cdf153d 100644 --- a/predict/index.php +++ b/predict/index.php @@ -25,9 +25,11 @@ var current_uuid = ' var map; var map_items = []; -var launch_img = "images/marker-sm-red.png"; -var land_img = "images/marker-sm-red.png"; +var launch_img = "images/target-1-sm.png"; +var land_img = "images/target-8-sm.png"; var burst_img = "images/pop-marker.png"; +var clickListener; +var clickMarker; function initialize() { // make the map and set center @@ -59,6 +61,20 @@ function initialize() { } } }); + // activate the "Set with Map" link + $("#setWithClick").click(function() { + setLatLonByClick(true); + }); + // attach onchange handlers to the lat/long boxes + $("#lat").change(function() { + plotClick(); + }); + $("#lon").change(function() { + plotClick(); + }); + $("#site").change(function() { + plotClick(); + }); $("#input_form").draggable({containment: '#map_canvas'}); if ( current_uuid != '0' ) { appendDebug("Got an old UUID to plot:
" + current_uuid); @@ -78,6 +94,8 @@ function initialize() { toggleWindow("input_form", "showHideForm", "Show Launch Card", "Hide Launch Card"); }); + // plot the initial launch location + plotClick(); } @@ -103,7 +121,7 @@ function initialize() {

Scenario Information

- +Lat: Lon:
Show Debug
| Hide Launch Card
@@ -124,7 +142,7 @@ function initialize() { - Latitude: + Latitude: Set with map diff --git a/predict/js/pred.js b/predict/js/pred.js index 7aa6d14..a51534c 100644 --- a/predict/js/pred.js +++ b/predict/js/pred.js @@ -122,6 +122,10 @@ function parseCSV(lines) { var path = []; var max_height = -10; //just any -ve number var max_point = null; + var launch_lat; + var launch_lon; + var land_lat; + var land_lon; var launch_pt; var land_pt; $.each(lines, function(idx, line) { @@ -129,15 +133,15 @@ function parseCSV(lines) { if(entry.length >= 4) { // check valid entry length var point = new google.maps.LatLng( parseFloat(entry[1]), parseFloat(entry[2]) ); if ( idx == 0 ) { // get the launch lat/long for marker - var launch_lat = entry[1]; - var launch_lon = entry[2]; + launch_lat = entry[1]; + launch_lon = entry[2]; launch_pt = point; } // set on every iteration, last valid entry // gives landing position - var land_lat = entry[1]; - var land_lon = entry[2]; + land_lat = entry[1]; + land_lon = entry[2]; land_pt = point; if(parseFloat(entry[3]) > max_height) { @@ -168,14 +172,14 @@ function parseCSV(lines) { position: launch_pt, map: map, icon: launch_icon, - title: 'Balloon launch' + title: 'Balloon launch ('+launch_lat+', '+launch_lon+')' }); var land_marker = new google.maps.Marker({ position: land_pt, map:map, icon: land_icon, - title: 'Predicted Landing' + title: 'Predicted Landing ('+land_lat+', '+land_lon+')' }); var path_polyline = new google.maps.Polyline({ @@ -207,6 +211,49 @@ function parseCSV(lines) { } +function plotClick() { + // clear the old marker + clearMapItems(); + // get the new values from the form + click_lat = parseFloat($("#lat").val()); + click_lon = parseFloat($("#lon").val()); + var click_pt = new google.maps.LatLng(click_lat, click_lon); + clickMarker = new google.maps.Marker({ + position: click_pt, + map: map, + icon: 'images/target-1-sm.png', + title: 'Currently selected launch location ('+click_lat+', '+click_lon+')' + }); + map_items.push(clickMarker); + map.panTo(click_pt); + map.setZoom(8); +} + + +function setFormLatLon(GLatLng) { + $("#lat").val(GLatLng.lat().toFixed(4)); + $("#lon").val(GLatLng.lng().toFixed(4)); + // remove the event handler so another click doesn't register + setLatLonByClick(false); + // change the dropdown to read "other" + SetSiteOther(); + // plot the new marker for launch location + plotClick(); +} + +function setLatLonByClick(state) { + if ( state == true ) { + clickListener = google.maps.event.addListener(map, 'click', function(event) { + setFormLatLon(event.latLng); + }); + } else if ( state == false ) { + google.maps.event.removeListener(clickListener); + } else { + appendDebug("Unrecognised state for setLatLonByClick"); + } + +} + function enableMap(map, state) { if ( state != false && state != true) { appendDebug("Unrecognised map state"); @@ -299,8 +346,6 @@ function UpdateLaunchSite(id) { function SetSiteOther() { optOther = document.getElementById("other"); - //cmbSite = document.getElementById("site"); - //cmbSite.selectedIndex = 1; optOther.selected = true; }