Skip to content

Instantly share code, notes, and snippets.

@bamnet
Created September 20, 2018 04:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bamnet/7fd0f87d0ff569cca650457c3c25a556 to your computer and use it in GitHub Desktop.
Save bamnet/7fd0f87d0ff569cca650457c3c25a556 to your computer and use it in GitHub Desktop.
<style id="jsbin-css">
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 100%;
}
/* Optional: Makes the sample page fill the window. */
html, body {
height: 100%;
margin: 0;
padding: 0;
}
</style>
<div id="map"></div>
<!-- Replace the value of the key parameter with your own API key. -->
<script src="https://maps.googleapis.com/maps/api/js?callback=initMap" async defer></script>
<script id="jsbin-javascript">
var map;
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
center: {lat: 40.63801310485752, lng: -74.17071700376579},
zoom: 10
});
loadData();
}
async function loadData() {
let response = await fetch('http://njtdev.endpoints.njtapi-dev.cloud.goog:8080/v1/stations/SE/departures?stop=New%20York');
let data = await response.json();
for(const row of data.departures) {
if(row.location) {
const latlng = row.location.latLng;
const ll = {lat: parseFloat(latlng.latitude), lng: parseFloat(latlng.longitude)};
console.log(ll);
const marker = new google.maps.Marker({position: ll, map: map});
}
}
}
</script>
<script id="jsbin-source-css" type="text/css">/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 100%;
}
/* Optional: Makes the sample page fill the window. */
html, body {
height: 100%;
margin: 0;
padding: 0;
}</script>
<script id="jsbin-source-javascript" type="text/javascript">var map;
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
center: {lat: 40.63801310485752, lng: -74.17071700376579},
zoom: 10
});
loadData();
}
async function loadData() {
let response = await fetch('http://njtdev.endpoints.njtapi-dev.cloud.goog:8080/v1/stations/SE/departures?stop=New%20York');
let data = await response.json();
for(const row of data.departures) {
if(row.location) {
const latlng = row.location.latLng;
const ll = {lat: parseFloat(latlng.latitude), lng: parseFloat(latlng.longitude)};
console.log(ll);
const marker = new google.maps.Marker({position: ll, map: map});
}
}
}</script>
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 100%;
}
/* Optional: Makes the sample page fill the window. */
html, body {
height: 100%;
margin: 0;
padding: 0;
}
var map;
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
center: {lat: 40.63801310485752, lng: -74.17071700376579},
zoom: 10
});
loadData();
}
async function loadData() {
let response = await fetch('http://njtdev.endpoints.njtapi-dev.cloud.goog:8080/v1/stations/SE/departures?stop=New%20York');
let data = await response.json();
for(const row of data.departures) {
if(row.location) {
const latlng = row.location.latLng;
const ll = {lat: parseFloat(latlng.latitude), lng: parseFloat(latlng.longitude)};
console.log(ll);
const marker = new google.maps.Marker({position: ll, map: map});
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment