if (document.getElementById("membermap") !== null) {
  L.Icon.Default.imagePath = '/assets';

  var default_marker_icon = L.icon({
    iconUrl: "<%=image_url('spade-marker.svg')%>",
    iconSize: [48, 48],
    iconAnchor: [24, 48],
    popupAnchor: [0, -46],
  });

  $.getJSON(location.pathname + '.json', function(member) {
    if (member.latitude && member.longitude) {
      var membermap = L.map('membermap').setView([member.latitude, member.longitude], 4);

      L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
        attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
        maxZoom: 18
      }).addTo(membermap);
      var marker = new L.Marker(new L.LatLng(member.latitude, member.longitude),
          {'icon': default_marker_icon});

      var member_url = "/members/" + member.slug;
      var member_link = "<a href='" + member_url + "'>" + member.login_name + "</a>";

      var where = "<p><i>" + member.location + "</i></p>";

      marker.bindPopup(member_link + where).openPopup();
      marker.addTo(membermap);
    }
  });

}
