From 0a61d18ba0088b378fcfab6498b3a1c42f9c029f Mon Sep 17 00:00:00 2001 From: Kumar Damani Date: Thu, 28 Feb 2019 00:40:15 -0700 Subject: sending geo data to front end, displaying it as markers, and taken out schema defs from index into models folder --- web/public/javascripts/map.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'web/public/javascripts/map.js') diff --git a/web/public/javascripts/map.js b/web/public/javascripts/map.js index 5e5a303..70c1419 100644 --- a/web/public/javascripts/map.js +++ b/web/public/javascripts/map.js @@ -12,10 +12,11 @@ L.tileLayer('https://stamen-tiles-{s}.a.ssl.fastly.net/toner-lite/{z}/{x}/{y}{r} ext: 'png' }).addTo(map); -// Create point feature for somewhere downtown -var myDataPoint = L.marker([43.6529, -79.3849]).addTo(map); - -// Bind popup to Data Point object -myDataPoint.bindPopup("

City Hall (not really)

Toronto, ON
Information about city hall.

"); - -map.setZoom(13); +L.geoJson(dumbpoints, { + pointToLayer: function (feature, latlng) { + //return L.circleMarker(latlng); + return L.marker(latlng); + } +}).bindPopup(function (layer) { + return layer.feature.geometry.another; +}).addTo(map) -- cgit v1.2.3 From 9764fba35cdac7e226dad65f061c09fd3d9909cc Mon Sep 17 00:00:00 2001 From: Kumar Damani Date: Thu, 28 Feb 2019 10:32:26 -0700 Subject: displaying all the fields in the marker popup, better var naming --- web/public/javascripts/map.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'web/public/javascripts/map.js') diff --git a/web/public/javascripts/map.js b/web/public/javascripts/map.js index 70c1419..190307d 100644 --- a/web/public/javascripts/map.js +++ b/web/public/javascripts/map.js @@ -12,11 +12,12 @@ L.tileLayer('https://stamen-tiles-{s}.a.ssl.fastly.net/toner-lite/{z}/{x}/{y}{r} ext: 'png' }).addTo(map); -L.geoJson(dumbpoints, { +L.geoJson(points, { pointToLayer: function (feature, latlng) { //return L.circleMarker(latlng); return L.marker(latlng); } }).bindPopup(function (layer) { - return layer.feature.geometry.another; + // layer.feature.geometry gives you access to all the fields + return "

" + JSON.stringify(layer.feature.geometry) + "

"; }).addTo(map) -- cgit v1.2.3