Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Commit

Permalink
make coverage toggleable and fix onInit event
Browse files Browse the repository at this point in the history
  • Loading branch information
nborrmann committed Jul 27, 2016
1 parent ba22c20 commit 26f3a6c
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions static/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,21 @@ try {
console.log(excludedPokemon);
} catch (e) {}

var d = "displayPokemons" in localStorage ? localStorage.displayPokemons : 'true';
document.getElementById('pokemon-checkbox').checked = (d === 'true');
d = "displayGyms" in localStorage ? localStorage.displayGyms : 'true';
document.getElementById('gyms-checkbox').checked = (d === 'true');

function getFromStorage(keyName, default_value) {
var res = localStorage.getItem(keyName);
if(res){
return res === "true";
} else {
return default_value;
}
}

document.getElementById('pokemon-checkbox').checked = getFromStorage("displayPokemons", "true");
document.getElementById('gyms-checkbox').checked = getFromStorage("displayGyms", "true");
document.getElementById('coverage-checkbox').checked = getFromStorage("displayCoverage", "true");


$.getJSON("static/locales/pokemon.en.json").done(function(data) {
var pokeList = [];

Expand Down Expand Up @@ -65,6 +75,8 @@ function initMap() {
streetViewControl: false,
disableAutoPan: true
});

updateMap();

currentLocationMarker = new google.maps.Marker({
position: {lat: center_lat, lng: center_lng},
Expand Down Expand Up @@ -239,7 +251,6 @@ function updateMap() {
animation: google.maps.Animation.DROP
});

console.log("is different");
if (coverCircle) {
coverCircle.setCenter(searchLocation);
coverCircle.setRadius(searchLocation['radius']);
Expand All @@ -255,9 +266,8 @@ function updateMap() {
center: searchLocation,
radius: searchLocation['radius']
});
coverCircle.setVisible(document.getElementById('coverage-checkbox').checked);
}
} else {
console.log("not different");
}

$.each(result.pokemons, function(i, item){
Expand Down Expand Up @@ -303,7 +313,6 @@ function updateMap() {
}

window.setInterval(updateMap, 10000);
updateMap();

$('#gyms-checkbox').change(function() {
localStorage.displayGyms = this.checked;
Expand All @@ -329,6 +338,11 @@ $('#pokemon-checkbox').change(function() {
}
});

$('#coverage-checkbox').change(function() {
localStorage.displayCoverage = this.checked;
coverCircle.setVisible(this.checked);
});

var coverCircles = [];
/*
function displayCoverage() {
Expand Down

0 comments on commit 26f3a6c

Please sign in to comment.