Draws a lat-lon delta square around launch position closes #40
rodzic
7d8f124a34
commit
c62351aaaf
|
@ -120,6 +120,12 @@ function initialize() {
|
||||||
$("#about_window_show").click(function() {
|
$("#about_window_show").click(function() {
|
||||||
$("#about_window").fadeIn();
|
$("#about_window").fadeIn();
|
||||||
});
|
});
|
||||||
|
$("#delta_lat").change(function() {
|
||||||
|
drawDeltaSquare(map);
|
||||||
|
});
|
||||||
|
$("#delta_lon").change(function() {
|
||||||
|
drawDeltaSquare(map);
|
||||||
|
});
|
||||||
// plot the initial launch location
|
// plot the initial launch location
|
||||||
plotClick();
|
plotClick();
|
||||||
google.maps.event.addListener(map, 'mousemove', function(event) {
|
google.maps.event.addListener(map, 'mousemove', function(event) {
|
||||||
|
|
|
@ -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() {
|
function plotClick() {
|
||||||
// clear the old marker
|
// clear the old marker
|
||||||
clearMapItems();
|
clearMapItems();
|
||||||
|
@ -307,10 +320,30 @@ function plotClick() {
|
||||||
title: 'Currently selected launch location ('+click_lat+', '+click_lon+')'
|
title: 'Currently selected launch location ('+click_lat+', '+click_lon+')'
|
||||||
});
|
});
|
||||||
map_items['clickMarker'] = clickMarker;
|
map_items['clickMarker'] = clickMarker;
|
||||||
|
// redraw the delta square
|
||||||
|
drawDeltaSquare(map);
|
||||||
map.panTo(click_pt);
|
map.panTo(click_pt);
|
||||||
map.setZoom(8);
|
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) {
|
function setFormLatLon(GLatLng) {
|
||||||
$("#lat").val(GLatLng.lat().toFixed(4));
|
$("#lat").val(GLatLng.lat().toFixed(4));
|
||||||
|
|
Ładowanie…
Reference in New Issue