diff --git a/predict/index.php b/predict/index.php index d5b33c7..6e02dfa 100644 --- a/predict/index.php +++ b/predict/index.php @@ -120,6 +120,12 @@ function initialize() { $("#about_window_show").click(function() { $("#about_window").fadeIn(); }); + $("#delta_lat").change(function() { + drawDeltaSquare(map); + }); + $("#delta_lon").change(function() { + drawDeltaSquare(map); + }); // plot the initial launch location plotClick(); google.maps.event.addListener(map, 'mousemove', function(event) { diff --git a/predict/js/pred.js b/predict/js/pred.js index c3fde14..26d8866 100644 --- a/predict/js/pred.js +++ b/predict/js/pred.js @@ -293,6 +293,19 @@ function parseCSV(lines) { } +function drawPolygon(points, gmap_object) { + var newPoly = new google.maps.Polygon({ + paths: points, + strokeColor: "#FF0000", + strokeOpacity: 0.4, + fillColor: "#FFFFFF", + fillOpacity: 0, + strokeWeight: 2, + }); + map_items['delta_square'] = newPoly; + newPoly.setMap(gmap_object); +} + function plotClick() { // clear the old marker clearMapItems(); @@ -307,10 +320,30 @@ function plotClick() { title: 'Currently selected launch location ('+click_lat+', '+click_lon+')' }); map_items['clickMarker'] = clickMarker; + // redraw the delta square + drawDeltaSquare(map); map.panTo(click_pt); map.setZoom(8); } +function drawDeltaSquare(map) { + // clear any old squares + if ( map_items['delta_square'] ) map_items['delta_square'].setMap(null); + // get the values from the form + var lat = parseFloat($("#lat").val()); + var lon = parseFloat($("#lon").val()); + var dlon = parseFloat($("#delta_lat").val()); + var dlat = parseFloat($("#delta_lon").val()); + // make a rectange of points + var points = [ + new google.maps.LatLng(lat+dlat, lon+dlon), + new google.maps.LatLng(lat-dlat, lon+dlon), + new google.maps.LatLng(lat-dlat, lon-dlon), + new google.maps.LatLng(lat+dlat, lon-dlon) + ] + // write the poly to the map + drawPolygon(points, map); +} function setFormLatLon(GLatLng) { $("#lat").val(GLatLng.lat().toFixed(4));