Skip to content

Commit

Permalink
Fix location map
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandermendes committed Nov 15, 2016
1 parent 5cefe19 commit 96db543
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 9,727 deletions.
38 changes: 0 additions & 38 deletions libcrowds_statistics/static/css/vendor/MarkerCluster.Default.css

This file was deleted.

6 changes: 0 additions & 6 deletions libcrowds_statistics/static/css/vendor/MarkerCluster.css

This file was deleted.

42 changes: 22 additions & 20 deletions libcrowds_statistics/static/js/charts.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,36 +230,38 @@ function populateLocationsSummary(stats, id) {

/** Populate the locations chart. */
function populateLocationsChart(locs, id) {
console.log(locs);
if(locs.length > 0) {
$('#' + id).slideDown();
var map = L.map('map', {scrollWheelZoom: false, minZoom:1});
$(`#${id}`).slideDown();
let map = L.map('map', {scrollWheelZoom: false, minZoom:1});
let token = 'pk.eyJ1IjoibGliY3Jvd2RzIiwiYSI6ImNpdmlxaHFzNTAwN3YydHBncHV3dHc3aXgifQ.V4WUx9SDcU_XLFJo2M3RxQ';
let url = `https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=${token}`;
map.fitWorld();
map.setZoom(2);
var url = 'http://{s}.tile.osm.org/{z}/{x}/{y}.png'
L.tileLayer(url,
{
attribution: '&copy; <a href="http://osm.org/copyright"> \
OpenStreetMap \
</a> &mdash; \
<a href="http://www.maxmind.com"> \
MaxMind \
</a>',
maxZoom: 18
}).addTo(map);
var i = 0;
var locations = locs;
var l = locations.length;
var markers = new L.MarkerClusterGroup();
L.tileLayer(url, {
attribution: `Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors,
<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery &copy;
<a href="http://mapbox.com">Mapbox</a>`,
maxZoom: 18,
id: 'mapbox.streets',
accessToken: token
}).addTo(map);
console.log(url);

let i = 0;
let locations = locs;
let l = locations.length;
let markers = new L.MarkerClusterGroup();
for (i;i<l;i++) {
if (locations[i].loc != null) {
var lat = parseFloat(locations[i].loc.latitude);
var lng = parseFloat(locations[i].loc.longitude);
let lat = parseFloat(locations[i].loc.latitude);
let lng = parseFloat(locations[i].loc.longitude);
markers.addLayer(L.marker([lat,lng]));
}
}
map.addLayer(markers);
} else {
$("#locations").hide();
$(`#${id}`).hide();
}
}

Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 96db543

Please sign in to comment.