|
52 | 52 | </div>
|
53 | 53 |
|
54 | 54 |
|
55 |
| - <link rel="stylesheet" href="https://unpkg.com/leaflet@1.0.3/dist/leaflet.css"> |
| 55 | + <link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css"> |
56 | 56 | <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
|
57 | 57 | <script src="https://cdnjs.cloudflare.com/ajax/libs/what-input/4.0.6/what-input.min.js"></script>
|
58 | 58 | <script src="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.3.0/js/foundation.min.js"></script>
|
59 | 59 | <script src=" https://cdn.jsdelivr.net/npm/[email protected]/papaparse.min.js" ></script>
|
60 | 60 | <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.6.0/d3.min.js"></script>
|
61 |
| - <script src="https://unpkg.com/leaflet@1.0.3/dist/leaflet.js"></script> |
| 61 | + <script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"></script> |
62 | 62 | <!-- <script src="https://use.fontawesome.com/eb154e6e77.js"></script> -->
|
63 | 63 |
|
64 | 64 | <script>
|
|
281 | 281 |
|
282 | 282 |
|
283 | 283 | // get the contact data from the google spreadhsheet
|
284 |
| - var publicSpreadsheetUrl = 'https://docs.google.com/spreadsheets/d/e/2PACX-1vT12UwGG1A10zICCvRL5tcd4uF89xXNOQ9RS4R9vDLax7H2vMKOUV3kODbFAA5RPP6LQathslaUIO-9/pub?gid=1040223163&single=true&output=csv'; |
| 284 | + var publicSpreadsheetUrl = '{{ site.baseurl }}/assets/google-sheets/eventHelpers.csv'; |
285 | 285 | function init() {
|
286 | 286 | Papa.parse(publicSpreadsheetUrl, {
|
287 | 287 | download: true,
|
|
357 | 357 | subdomains: 'abcd',
|
358 | 358 | maxZoom: 19
|
359 | 359 | }).addTo(map);
|
360 |
| - |
361 |
| - // initialize the SVG layer for D3 drawn markers |
362 |
| - L.svg().addTo(map); |
363 |
| - // pick up the SVG from the map object |
364 |
| - var svg = d3.select('#map').select('svg'); |
365 |
| - markersGroup = svg.append('g').attr('id', 'markers').attr('class', 'leaflet-zoom-hide'); |
366 |
| - |
367 |
| - // add markers to the map for each contact |
368 |
| - mappedContacts = d3.select('svg #markers').selectAll('text').data(validMarkers) |
369 |
| - .enter().append('text') |
370 |
| - .text('\uf276') |
371 |
| - .attr('font-family', 'FontAwesome') |
372 |
| - .attr('class', function(d) { |
373 |
| - if(d[supportKey].length === 1) { |
374 |
| - return 'map-font ' + supportClass(d[supportKey][0]); |
375 |
| - } else { return 'map-font help_all'; } |
376 |
| - }) |
377 |
| - .classed('mapmarker', true) |
378 |
| - .on('click', function(d) { |
379 |
| - var lang = []; |
380 |
| - $.each(d[languageKey], function(i, item){ lang.push(languageLookup[item]); }); |
381 |
| - var support = []; |
382 |
| - $.each(d[supportKey], function(i, item) { |
383 |
| - support.push('<span class="' + supportClass(item) + '">' + item + '</span>'); |
384 |
| - }); |
385 |
| - var supportHtml = support.join(', '); |
386 |
| - var htmlpop = '<div><b>' + osmHtml(d[osmKey]) + ' ' + d[nameKey] + '</b></div>' + |
387 |
| - '<div>' + |
388 |
| - supportHtml + '<br>' + |
389 |
| - contactInfo(d[emailKey], d[phoneKey], d[skypeKey], d[twitterKey]) + '<br>' + |
390 |
| - '<i class="fa fa-fw fa-language" aria-hidden="true"></i> ' + lang.join('; ') + '<br>' + |
391 |
| - '<em>' + d[noteKey] + '</em>' + |
392 |
| - '</div>'; |
393 |
| - var popup = L.popup({closeOnClick: false}) |
394 |
| - .setLatLng(d.LatLng) |
395 |
| - .setContent(htmlpop) |
396 |
| - .openOn(map); |
| 360 | + |
| 361 | + validMarkers.forEach(function(d, index){ |
| 362 | + var marker = L.marker(d.LatLng) |
| 363 | + var lang = []; |
| 364 | + $.each(d[languageKey], function(i, item){ lang.push(languageLookup[item]); }); |
| 365 | + var support = []; |
| 366 | + $.each(d[supportKey], function(i, item) { |
| 367 | + support.push('<span class="' + supportClass(item) + '">' + item + '</span>'); |
397 | 368 | });
|
398 |
| - |
399 |
| - // when map view changes adjust the locations of the svg circles |
400 |
| - updatemarker = function() { |
401 |
| - mappedContacts.attr('x',function(d) { return map.latLngToLayerPoint(d.LatLng).x; }); |
402 |
| - mappedContacts.attr('y',function(d) { return map.latLngToLayerPoint(d.LatLng).y; }); |
403 |
| - } |
404 |
| - // set the starting locations of the markers |
405 |
| - updatemarker(); |
| 369 | + var supportHtml = support.join(', '); |
| 370 | + var htmlpop = '<div><b>' + osmHtml(d[osmKey]) + ' ' + d[nameKey] + '</b></div>' + |
| 371 | + '<div>' + |
| 372 | + supportHtml + '<br>' + |
| 373 | + contactInfo(d[emailKey], d[phoneKey], d[skypeKey], d[twitterKey]) + '<br>' + |
| 374 | + '<i class="fa fa-fw fa-language" aria-hidden="true"></i> ' + lang.join('; ') + '<br>' + |
| 375 | + '<em>' + d[noteKey] + '</em>' + |
| 376 | + '</div>'; |
| 377 | + marker.bindPopup(htmlpop); |
| 378 | + marker.addTo(map); |
| 379 | + }); |
| 380 | + |
| 381 | + |
| 382 | + // ############ |
| 383 | + // ## using D3 to render SVG was really bogging down for some reason |
| 384 | + // ############ |
| 385 | + |
| 386 | + // // initialize the SVG layer for D3 drawn markers |
| 387 | + // L.svg().addTo(map); |
| 388 | + // // pick up the SVG from the map object |
| 389 | + // var svg = d3.select('#map').select('svg'); |
| 390 | + // markersGroup = svg.append('g').attr('id', 'markers').attr('class', 'leaflet-zoom-hide'); |
| 391 | + // |
| 392 | + // // add markers to the map for each contact |
| 393 | + // mappedContacts = d3.select('svg #markers').selectAll('text').data(validMarkers) |
| 394 | + // .enter().append('text') |
| 395 | + // .text('\uf276') |
| 396 | + // .attr('font-family', 'FontAwesome') |
| 397 | + // .attr('class', function(d) { |
| 398 | + // if(d[supportKey].length === 1) { |
| 399 | + // return 'map-font ' + supportClass(d[supportKey][0]); |
| 400 | + // } else { return 'map-font help_all'; } |
| 401 | + // }) |
| 402 | + // .classed('mapmarker', true) |
| 403 | + // .on('click', function(d) { |
| 404 | + // var lang = []; |
| 405 | + // $.each(d[languageKey], function(i, item){ lang.push(languageLookup[item]); }); |
| 406 | + // var support = []; |
| 407 | + // $.each(d[supportKey], function(i, item) { |
| 408 | + // support.push('<span class="' + supportClass(item) + '">' + item + '</span>'); |
| 409 | + // }); |
| 410 | + // var supportHtml = support.join(', '); |
| 411 | + // var htmlpop = '<div><b>' + osmHtml(d[osmKey]) + ' ' + d[nameKey] + '</b></div>' + |
| 412 | + // '<div>' + |
| 413 | + // supportHtml + '<br>' + |
| 414 | + // contactInfo(d[emailKey], d[phoneKey], d[skypeKey], d[twitterKey]) + '<br>' + |
| 415 | + // '<i class="fa fa-fw fa-language" aria-hidden="true"></i> ' + lang.join('; ') + '<br>' + |
| 416 | + // '<em>' + d[noteKey] + '</em>' + |
| 417 | + // '</div>'; |
| 418 | + // var popup = L.popup({closeOnClick: false}) |
| 419 | + // .setLatLng(d.LatLng) |
| 420 | + // .setContent(htmlpop) |
| 421 | + // .openOn(map); |
| 422 | + // }); |
| 423 | + // |
| 424 | + // // when map view changes adjust the locations of the svg circles |
| 425 | + // updatemarker = function() { |
| 426 | + // mappedContacts.attr('x',function(d) { return map.latLngToLayerPoint(d.LatLng).x; }); |
| 427 | + // mappedContacts.attr('y',function(d) { return map.latLngToLayerPoint(d.LatLng).y; }); |
| 428 | + // } |
| 429 | + // // set the starting locations of the markers |
| 430 | + // updatemarker(); |
406 | 431 |
|
407 | 432 | filter = function(){
|
408 | 433 |
|
|
497 | 522 | }
|
498 | 523 |
|
499 | 524 | toggleMarkerVis = function(language, type) {
|
500 |
| - mappedContacts.each(function(d) { |
501 |
| - if( (($.inArray(language, d[languageKey]) !== -1) || (language == 'all')) && ( ($.inArray(type, d[supportKey]) !== -1) || (type == 'all')) ){ |
502 |
| - d3.select(this).classed('no-language', false); |
503 |
| - } else { |
504 |
| - d3.select(this).classed('no-language', true); |
505 |
| - } |
506 |
| - }); |
| 525 | + // mappedContacts.each(function(d) { |
| 526 | + // if( (($.inArray(language, d[languageKey]) !== -1) || (language == 'all')) && ( ($.inArray(type, d[supportKey]) !== -1) || (type == 'all')) ){ |
| 527 | + // d3.select(this).classed('no-language', false); |
| 528 | + // } else { |
| 529 | + // d3.select(this).classed('no-language', true); |
| 530 | + // } |
| 531 | + // }); |
507 | 532 | }
|
508 | 533 |
|
509 | 534 |
|
510 | 535 | // when map view changes check what markers are visible in the extent
|
511 | 536 | map.on('load moveend zoomend viewreset', filter);
|
512 | 537 | // filter();
|
513 | 538 |
|
514 |
| - // when map view changes adjust the locations of the markers |
515 |
| - map.on('zoom move viewreset', updatemarker); |
| 539 | + // // when map view changes adjust the locations of the markers |
| 540 | + // map.on('zoom move viewreset', updatemarker); |
516 | 541 |
|
517 | 542 | $('#language-filter').change(function(){
|
518 | 543 | filter();
|
|
0 commit comments