Skip to content

Commit

Permalink
Added point when searching for address, #28
Browse files Browse the repository at this point in the history
  • Loading branch information
cambark committed Aug 9, 2019
1 parent 7839d17 commit 2576019
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ We use the Fetch API for browser-based Web requests to the Carto SQL API and the

### SLAM v0.9e
* [[24]](../../../../BetaNYC/SLAM/issues/24) Upated SQL queries to match column names in SLA dataset
* [[28]](../../../../BetaNYC/SLAM/issues/28) Added point to map when searching for a specific address.

### SLAM v0.8e
* [[22]](../../../../BetaNYC/SLAM/issues/22) Display schools and churches as polygons on the map.
Expand Down
3 changes: 2 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ <h4>Search</h4>

<!-- source info -->
<div id="source"></div>
<a href="#" onclick="toggle_visibility('info_box');" class="close_button">Close Window</a>
<a href="#" onclick="toggle_visibility('info_box');if(marker){marker.remove()};" class="close_button">Close Window</a>
</div>
<footer class="js-footer"></footer>
</aside>
Expand All @@ -166,6 +166,7 @@ <h4>Search</h4>
//set map view
const map = L.map('map').setView([40.73, -74], 18);
map.scrollWheelZoom.disable();
var marker;

//set basemap
L.tileLayer('https://cartodb-basemaps-{s}.global.ssl.fastly.net/rastertiles/voyager/{z}/{x}/{y}{r}.png', {
Expand Down
7 changes: 7 additions & 0 deletions scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ function set_address() {
longitude = response.longitude;
//set map view to the resulting lat, lon and zoom to 18
map.setView([latitude, longitude], 18);
if(marker) {
marker.remove();
}
marker = L.marker([latitude, longitude]).addTo(map);
})
.catch(function(error) {
//if nothing gets returned, display no results
Expand Down Expand Up @@ -101,4 +105,7 @@ function clear_charts() {
//Filters
function reset_map() {
map.setView([40.73, -74], 18);
if(marker) {
marker.remove();
}
}

0 comments on commit 2576019

Please sign in to comment.