Draws a lat-lon delta square around launch position closes #40

pull/73/head
jonsowman 2010-06-08 15:16:20 +01:00
rodzic 7d8f124a34
commit c62351aaaf
2 zmienionych plików z 39 dodań i 0 usunięć

Wyświetl plik

@ -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) {

Wyświetl plik

@ -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));