Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am poltib on github.
  • I am poltib (https://keybase.io/poltib) on keybase.
  • I have a public key ASAS40zf1vwhOYwwcfbvfVjahF8XwhsZXdCnOvZZjJVbNgo

To claim this, I am signing this object:

@poltib
poltib / gist:11315915
Created April 26, 2014 09:42
gmap_script_listeners
google.maps.event.addListener(map, 'click', function(evt) {
if (path.getLength() === 0) {
path.push(evt.latLng);
poly.setPath(path);
} else {
return grow_path(path.getAt(path.getLength() - 1), evt.latLng);
}
});
reset.addEventListener('click', function(evt) {
@poltib
poltib / gist:11315906
Created April 26, 2014 09:41
gmap_script_var
var clear, close, dist, divMap, elevation_chart, grow_path, map, reset;
dist = document.getElementById("dist");
reset = document.getElementById("reset");
close = document.getElementById("close");
clear = document.getElementById("clear");
full = document.getElementById("full");
divMap = document.getElementById("map_canvas");
elevation_chart = document.getElementById('elevation_chart');
chart = new google.visualization.ColumnChart(elevation_chart);
map = gm_init();
@poltib
poltib / gist:11315885
Created April 26, 2014 09:40
gmap_script_distance
google.maps.LatLng.prototype.kmTo = function(a) {
var b, c, d, e, f, g, ra;
e = Math;
ra = e.PI / 180;
b = this.lat() * ra;
c = a.lat() * ra;
d = b - c;
g = this.lng() * ra - a.lng() * ra;
f = 2 * e.asin(e.sqrt(e.pow(e.sin(d / 2), 2) + e.cos(b) * e.cos(c) * e.pow(e.sin(g / 2), 2)));
return f * 6378.137;
@poltib
poltib / gist:11315868
Created April 26, 2014 09:40
gmap_script_growpath
grow_path = function(origin, destination) {
return gm_service.route({
origin: origin,
destination: destination,
travelMode: google.maps.DirectionsTravelMode.WALKING
}, function(result, status) {
var coords, i, _ref;
if (status !== google.maps.DirectionsStatus.OK) {
return;
}
@poltib
poltib / gist:11315849
Created April 26, 2014 09:39
gmap_script_plotelevation
plot_elevation = function(results, status) {
var data, i;
elevation_req_active = false;
if (status !== google.maps.ElevationStatus.OK) {
return;
}
elevations = results;
data = new google.visualization.DataTable();
data.addColumn('string', 'Sample');
data.addColumn('number', 'Elevation');
@poltib
poltib / gist:11315836
Created April 26, 2014 09:38
gmap_script_drawpath
draw_path = function(path) {
var pathRequest;
if (elevation_req_active || !path) {
r eturn;
}
pathRequest = {
path: path,
samples: SAMPLES
};
elevation_req_active = true;
@poltib
poltib / gist:11315826
Created April 26, 2014 09:37
gmap_script_polyinit
poly_init = function(map) {
var poly_options;
poly_options = {
draggable: true,
editable: true,
geodesic: true,
map: map,
strokeColor: 'rgba(0,0,0,0.6)'
};
return new google.maps.Polyline(poly_options);
@poltib
poltib / gist:11315792
Created April 26, 2014 09:34
gmap_script_gmapinit
gm_init = function() {
var gm_center, gm_map_type, map_options;
gm_center = new google.maps.LatLng(50.633333, 5.566667);
gm_map_type = google.maps.MapTypeId.ROADMAP;
map_options = {
zoom: 14,
center: gm_center,
panControl: false,
backgroundColor: "rgba(0,0,0,0)",
mapTypeControl: false,
@poltib
poltib / gist:11315766
Created April 26, 2014 09:33
gmap_script_globals
var NUMBER_DOT_TWONUMBERS, SAMPLES, alert, calc_bounds, chart, display_on_map, draw_path, elevation_req_active, elevation_service, elevations, gm_init, gm_service, path, plot_elevation, poly_init;
NUMBER_DOT_TWONUMBERS = /^(\d+.)(\d{0,2})(\d+)/;
poly = 1;
chart = 1;
elevations = 1;