Click to set launch location, auto pan to new, new icons

pull/73/head
jonsowman 2010-06-03 19:49:06 +01:00
rodzic 6e62e5b816
commit 8209d2dbbe
7 zmienionych plików z 79 dodań i 13 usunięć

Wyświetl plik

@ -11,7 +11,10 @@ body {
a { text-decoration: underline; color: #333; cursor: pointer; } a { text-decoration: underline; color: #333; cursor: pointer; }
/* The whoppping map in the centre */ /* The whoppping map in the centre */
#map_canvas { width: 100%; height: 100%; } #map_canvas {
width: 100%;
height: 100%;
}
#status_message{ #status_message{
position: absolute; position: absolute;

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 575 B

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 432 B

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 521 B

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 557 B

Wyświetl plik

@ -25,9 +25,11 @@ var current_uuid = '<?php echo ( isset($_GET['uuid'])? $_GET['uuid'] : "0" ); ?>
var map; var map;
var map_items = []; var map_items = [];
var launch_img = "images/marker-sm-red.png"; var launch_img = "images/target-1-sm.png";
var land_img = "images/marker-sm-red.png"; var land_img = "images/target-8-sm.png";
var burst_img = "images/pop-marker.png"; var burst_img = "images/pop-marker.png";
var clickListener;
var clickMarker;
function initialize() { function initialize() {
// make the map and set center // 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'}); $("#input_form").draggable({containment: '#map_canvas'});
if ( current_uuid != '0' ) { if ( current_uuid != '0' ) {
appendDebug("Got an old UUID to plot:<br>" + current_uuid); appendDebug("Got an old UUID to plot:<br>" + current_uuid);
@ -78,6 +94,8 @@ function initialize() {
toggleWindow("input_form", "showHideForm", "Show Launch Card", toggleWindow("input_form", "showHideForm", "Show Launch Card",
"Hide Launch Card"); "Hide Launch Card");
}); });
// plot the initial launch location
plotClick();
} }
@ -103,7 +121,7 @@ function initialize() {
<div id="scenario_info" class="box"> <div id="scenario_info" class="box">
<h1>Scenario Information</h1> <h1>Scenario Information</h1>
<span id="from_launch_lat"> <span id="cursor_info">Lat: <span id="cursor_lat"></span> Lon: <span id="cursor_lon"></span></span><br />
<a><span id="showHideDebug">Show Debug</span></a></span> | <a><span id="showHideDebug">Show Debug</span></a></span> |
<a><span id="showHideForm">Hide Launch Card</span></a></span> <a><span id="showHideForm">Hide Launch Card</span></a></span>
</div> </div>
@ -124,7 +142,7 @@ function initialize() {
</select> </select>
</td> </td>
<tr> <tr>
<td>Latitude:</td> <td>Latitude: <a id="setWithClick">Set with map</a></td>
<td><input id="lat" type="text" name="lat" value="52.2135" onKeyDown="SetSiteOther()"></td> <td><input id="lat" type="text" name="lat" value="52.2135" onKeyDown="SetSiteOther()"></td>
</tr> </tr>
<tr> <tr>

Wyświetl plik

@ -122,6 +122,10 @@ function parseCSV(lines) {
var path = []; var path = [];
var max_height = -10; //just any -ve number var max_height = -10; //just any -ve number
var max_point = null; var max_point = null;
var launch_lat;
var launch_lon;
var land_lat;
var land_lon;
var launch_pt; var launch_pt;
var land_pt; var land_pt;
$.each(lines, function(idx, line) { $.each(lines, function(idx, line) {
@ -129,15 +133,15 @@ function parseCSV(lines) {
if(entry.length >= 4) { // check valid entry length if(entry.length >= 4) { // check valid entry length
var point = new google.maps.LatLng( parseFloat(entry[1]), parseFloat(entry[2]) ); var point = new google.maps.LatLng( parseFloat(entry[1]), parseFloat(entry[2]) );
if ( idx == 0 ) { // get the launch lat/long for marker if ( idx == 0 ) { // get the launch lat/long for marker
var launch_lat = entry[1]; launch_lat = entry[1];
var launch_lon = entry[2]; launch_lon = entry[2];
launch_pt = point; launch_pt = point;
} }
// set on every iteration, last valid entry // set on every iteration, last valid entry
// gives landing position // gives landing position
var land_lat = entry[1]; land_lat = entry[1];
var land_lon = entry[2]; land_lon = entry[2];
land_pt = point; land_pt = point;
if(parseFloat(entry[3]) > max_height) { if(parseFloat(entry[3]) > max_height) {
@ -168,14 +172,14 @@ function parseCSV(lines) {
position: launch_pt, position: launch_pt,
map: map, map: map,
icon: launch_icon, icon: launch_icon,
title: 'Balloon launch' title: 'Balloon launch ('+launch_lat+', '+launch_lon+')'
}); });
var land_marker = new google.maps.Marker({ var land_marker = new google.maps.Marker({
position: land_pt, position: land_pt,
map:map, map:map,
icon: land_icon, icon: land_icon,
title: 'Predicted Landing' title: 'Predicted Landing ('+land_lat+', '+land_lon+')'
}); });
var path_polyline = new google.maps.Polyline({ 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) { function enableMap(map, state) {
if ( state != false && state != true) { if ( state != false && state != true) {
appendDebug("Unrecognised map state"); appendDebug("Unrecognised map state");
@ -299,8 +346,6 @@ function UpdateLaunchSite(id) {
function SetSiteOther() { function SetSiteOther() {
optOther = document.getElementById("other"); optOther = document.getElementById("other");
//cmbSite = document.getElementById("site");
//cmbSite.selectedIndex = 1;
optOther.selected = true; optOther.selected = true;
} }