Skip to content

Commit

Permalink
Add sidebar feature highlighting on mouseover
Browse files Browse the repository at this point in the history
  • Loading branch information
bmcbride committed Jan 16, 2015
1 parent 2556f10 commit 8e76312
Showing 1 changed file with 21 additions and 22 deletions.
43 changes: 21 additions & 22 deletions assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ $(document).on("click", ".feature-row", function(e) {
sidebarClick(parseInt($(this).attr("id"), 10));
});

$(document).on("mouseover", ".feature-row", function(e) {
highlight.clearLayers().addLayer(L.circleMarker([$(this).attr("lat"), $(this).attr("lng")], highlightStyle));
});

$(document).on("mouseout", ".feature-row", function(e) {
highlight.clearLayers();
});

$("#about-btn").click(function() {
$("#aboutModal").modal("show");
$(".navbar-collapse.in").collapse("hide");
Expand Down Expand Up @@ -69,15 +77,15 @@ function syncSidebar() {
theaters.eachLayer(function (layer) {
if (map.hasLayer(theaterLayer)) {
if (map.getBounds().contains(layer.getLatLng())) {
$("#feature-list tbody").append('<tr class="feature-row" id="' + L.stamp(layer) + '"><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>');
$("#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>');
}
}
});
/* Loop through museums layer and add only features which are in the map bounds */
museums.eachLayer(function (layer) {
if (map.hasLayer(museumLayer)) {
if (map.getBounds().contains(layer.getLatLng())) {
$("#feature-list tbody").append('<tr class="feature-row" id="' + L.stamp(layer) + '"><td style="vertical-align: middle;"><img width="16" height="18" src="assets/img/museum.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>');
$("#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/museum.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>');
}
}
});
Expand Down Expand Up @@ -112,6 +120,12 @@ var mapquestHYB = L.layerGroup([L.tileLayer("http://{s}.mqcdn.com/tiles/1.0.0/sa

/* Overlay Layers */
var highlight = L.geoJson(null);
var highlightStyle = {
stroke: false,
fillColor: "#00FFFF",
fillOpacity: 0.7,
radius: 10
};

var boroughs = L.geoJson(null, {
style: function (feature) {
Expand Down Expand Up @@ -223,12 +237,7 @@ var subwayLines = L.geoJson(null, {
$("#feature-title").html(feature.properties.Line);
$("#feature-info").html(content);
$("#featureModal").modal("show");
highlight.clearLayers().addLayer(L.circleMarker([e.latlng.lat, e.latlng.lng], {
stroke: false,
fillColor: "#00FFFF",
fillOpacity: 0.7,
radius: 10
}));

}
});
}
Expand Down Expand Up @@ -285,15 +294,10 @@ var theaters = L.geoJson(null, {
$("#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]], {
stroke: false,
fillColor: "#00FFFF",
fillOpacity: 0.7,
radius: 10
}));
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)+'"><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>');
$("#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,
Expand Down Expand Up @@ -333,15 +337,10 @@ var museums = L.geoJson(null, {
$("#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]], {
stroke: false,
fillColor: "#00FFFF",
fillOpacity: 0.7,
radius: 10
}));
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)+'"><td style="vertical-align: middle;"><img width="16" height="18" src="assets/img/museum.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>');
$("#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/museum.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>');
museumSearch.push({
name: layer.feature.properties.NAME,
address: layer.feature.properties.ADRESS1,
Expand Down

0 comments on commit 8e76312

Please sign in to comment.