From 2576019d07e76880958df3f0c7fb8dcfbed08d1c Mon Sep 17 00:00:00 2001 From: cambark <34783294+cambark@users.noreply.github.com> Date: Fri, 9 Aug 2019 11:03:35 -0400 Subject: [PATCH] Added point when searching for address, #28 --- README.md | 1 + index.html | 3 ++- scripts/main.js | 7 +++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6fb0360..fd8beaf 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/index.html b/index.html index 2c81bf0..d90160d 100644 --- a/index.html +++ b/index.html @@ -156,7 +156,7 @@

Search

- Close Window + Close Window @@ -166,6 +166,7 @@

Search

//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', { diff --git a/scripts/main.js b/scripts/main.js index 20d3b45..9f2b114 100644 --- a/scripts/main.js +++ b/scripts/main.js @@ -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 @@ -101,4 +105,7 @@ function clear_charts() { //Filters function reset_map() { map.setView([40.73, -74], 18); + if(marker) { + marker.remove(); + } }