clean up selection method

This commit is contained in:
David 2017-03-26 19:58:40 -04:00
parent 0392056912
commit cd58689e86

View File

@ -113,18 +113,15 @@
} }
function updateSelectedStore(store) { function updateSelectedStore(store) {
var geometry = store.geometry ? store.geometry.coordinates : [store.long, store.lat]; map.flyTo({center: [store.long, store.lat]});
var properties = store.properties ? store.properties : store;
map.flyTo({center: geometry}); popup.setLngLat([store.long, store.lat])
.setHTML(store.name)
popup.setLngLat(geometry)
.setHTML(properties.name)
.addTo(map); .addTo(map);
$('#info').hide(); $('#info').hide();
var template = $('#selectedStore').html(); var template = $('#selectedStore').html();
var rendered = Mustache.render(template, {store: properties}); var rendered = Mustache.render(template, {store: store});
$('#selected').html(rendered); $('#selected').html(rendered);
$('#selected').show(); $('#selected').show();
} }
@ -176,7 +173,7 @@
if (features.length) { if (features.length) {
var store = features[0]; var store = features[0];
// Get coordinates from the symbol and center the map on those coordinates // Get coordinates from the symbol and center the map on those coordinates
updateSelectedStore(store); updateSelectedStore(store.properties);
} }
}); });