Created
November 2, 2016 17:45
-
-
Save okjodom/70f9f5319311f3f5f5b5f6b8916e8704 to your computer and use it in GitHub Desktop.
Template bootleaf layer loader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Empty layer placeholder to add to layer control for listening when to add/remove theaters to markerClusters layer */ | |
var theaterLayer = L.geoJson(null); | |
var theaters = L.geoJson(null, { | |
pointToLayer: function (feature, latlng) { | |
return L.marker(latlng, { | |
icon: L.icon({ | |
iconUrl: "assets/img/theater.png", | |
iconSize: [24, 28], | |
iconAnchor: [12, 28], | |
popupAnchor: [0, -25] | |
}), | |
title: feature.properties.NAME, | |
riseOnHover: true | |
}); | |
}, | |
onEachFeature: function (feature, layer) { | |
if (feature.properties) { | |
var content = "<table class='table table-striped table-bordered table-condensed'>" + "<tr><th>Name</th><td>" + feature.properties.NAME + "</td></tr>" + "<tr><th>Phone</th><td>" + feature.properties.TEL + "</td></tr>" + "<tr><th>Address</th><td>" + feature.properties.ADDRESS1 + "</td></tr>" + "<tr><th>Website</th><td><a class='url-break' href='" + feature.properties.URL + "' target='_blank'>" + feature.properties.URL + "</a></td></tr>" + "<table>"; | |
layer.on({ | |
click: function (e) { | |
$("#feature-title").html(feature.properties.NAME); | |
$("#feature-info").html(content); | |
$("#featureModal").modal("show"); | |
highlight.clearLayers().addLayer(L.circleMarker([feature.geometry.coordinates[1], feature.geometry.coordinates[0]], highlightStyle)); | |
} | |
}); | |
$("#feature-list tbody").append('<tr class="feature-row" id="' + L.stamp(layer) + '" lat="' + layer.getLatLng().lat + '" lng="' + layer.getLatLng().lng + '"><td style="vertical-align: middle;"><img width="16" height="18" src="assets/img/theater.png"></td><td class="feature-name">' + layer.feature.properties.NAME + '</td><td style="vertical-align: middle;"><i class="fa fa-chevron-right pull-right"></i></td></tr>'); | |
theaterSearch.push({ | |
name: layer.feature.properties.NAME, | |
address: layer.feature.properties.ADDRESS1, | |
source: "Theaters", | |
id: L.stamp(layer), | |
lat: layer.feature.geometry.coordinates[1], | |
lng: layer.feature.geometry.coordinates[0] | |
}); | |
} | |
} | |
}); | |
$.getJSON("data/DOITT_THEATER_01_13SEPT2010.geojson", function (data) { | |
theaters.addData(data); | |
map.addLayer(theaterLayer); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment