This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function displayTimes(points) { | |
var container = document.getElementById("listContainer"); | |
var list = points.map(function (point) { | |
return timedElementTemplate(point.name, secondsToHHMMSS(point.time)); | |
}).join(""); | |
container.innerHTML = list; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function timedElementTemplate(name, time) { | |
return `<li class="list-group-item">Name: ${name}<br>Time: ${time}</li>`; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style type="text/css"> | |
.map-marker { | |
font-size: 2em; | |
top: -0.75em; | |
left: -0.20em; | |
position: absolute; | |
} | |
.red { color: red; } | |
.green { color: green; } | |
.blue { color: blue; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.css" /> | |
<script src="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script> | |
</head> | |
<body> | |
<div id="map" style="height: 100%;"></div> | |
<script> | |
/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function setupMap(center) { | |
//Map set up | |
// The url template for OpenStreetMap tiles. | |
var osmUrl="http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"; | |
// Creates the tile layer | |
var osmTileLayer = L.tileLayer(osmUrl, {minZoom: 8, maxZoom: 15}); | |
// Adds the tile layer to the map and centers the view to the provided LatLng coordinates. | |
var map = L.map("map").addLayer(osmTileLayer).setView(center, 12); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// We will be querying for the White House of the United States | |
var startingLocation = "The White House, DC"; | |
// This will be the data format used for the jQuery AJAX request. | |
var geocodingRequest = { “query”: startingLocation }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var authHeaders = { | |
"X-Application-Id": "<your app id>", | |
"X-Api-Key": "<your app key>" | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.ajax({ | |
// The URL for our geocoding api | |
url : "http://api.traveltimeapp.com/v4/geocoding/search", | |
type: "get", | |
headers: authHeaders, | |
data: geocodingRequest, | |
contentType: "application/json; charset=UTF-8", | |
success: function(data) { | |
// Documentation for the response format: http://docs.traveltimeplatform.com/reference/geocoding-search/ | |
var coords = data.features[0].geometry.coordinates; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var radiusMiles = 10.0; | |
// Since Leaflet accepts meters we want to convert miles to meters | |
var radiusMeters = radiusMiles * 1609.344; | |
function drawRadius(map, center, radiusMeters) { | |
// Creates the radius circle and displays it on the map | |
L.circle(center, radiusMeters).addTo(map); | |
// Marks the location from which the radius is created | |
L.marker(center).addTo(map); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.css" /> | |
<script src="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script> | |
</head> | |
<body> | |
<div id="map" style="height: 100%;"></div> | |
<script> | |
// Map setup |