From 92625bb842d80faa33188306b918f2078c91e848 Mon Sep 17 00:00:00 2001 From: Kumar Damani Date: Tue, 26 Feb 2019 22:17:53 -0700 Subject: removed unnecessary db call breaking homepage due to db update --- web/README.md | 30 ++---------------------------- web/public/javascripts/map.js | 33 +-------------------------------- web/routes/index.js | 9 +++------ 3 files changed, 6 insertions(+), 66 deletions(-) diff --git a/web/README.md b/web/README.md index d470960..b7f02b3 100644 --- a/web/README.md +++ b/web/README.md @@ -13,34 +13,8 @@ `docker run -d --name mymongo -p 27017:27017 mongo` -2. enter inside the container: - - `docker exec -it mymongo mongo` - -3. run inside the interactive mongo shell: - - `use helpthehome` - -4. Put in some dummy data to start, run: - -``` -db.pointscollection.insert({ - "type": "MultiPoint", - "name": "points", - "color": "#0000ff", - "style": { - "radius": 8, - "fillColor": "#00ce00", - "color": "#008c00", - "weight": 2, - "opacity": 1, - "fillOpacity": 1 - }, - "coordinates": [-73.9580, 40.8003] -}) -``` - -5. Now you are ready to start the app: + +2. Now you are ready to start the app: From this directory: diff --git a/web/public/javascripts/map.js b/web/public/javascripts/map.js index 44fba38..414efee 100644 --- a/web/public/javascripts/map.js +++ b/web/public/javascripts/map.js @@ -8,45 +8,14 @@ L.tileLayer('https://stamen-tiles-{s}.a.ssl.fastly.net/toner-lite/{z}/{x}/{y}{r} attribution: 'Map tiles by Stamen Design, CC BY 3.0 — Map data © OpenStreetMap contributors', subdomains: 'abcd', minZoom: 0, - maxZoom: 20, + maxZoom: 13, ext: 'png' }).addTo(map); // Create point feature for somewhere downtown var myDataPoint = L.marker([43.6529, -79.3849]).addTo(map); -// Create line feature and add style and add to map -var myDataLine = L.polyline([ - [43.6529, -79.3849], - [43.6531, -79.3855]], - {color: 'red', weight: 10}).addTo(map); - -// Create area feature add style and add to map -var myArea = L.polygon([ - [43.650948, -79.385655], - [43.66, -79.388], - [43.6634, -79.4011], - [43.66, -79.4011]], - {color: 'blue', weight: 4}).addTo(map); - // Bind popup to Data Point object // myDataPoint.bindPopup("This is my city"); // i can add regular html to this too - neat! myDataPoint.bindPopup("

City Hall (not really)

Toronto, ON
Information about city hall.

"); - -// Bind popup to area object -myArea.bindPopup("U of T Campus (not really)"); - -// Create an Empty Popup -var popup = L.popup(); - -// Write function to set Properties of the Popup -function onMapClick(e) { - popup - .setLatLng(e.latlng) - .setContent("You clicked the map at " + e.latlng.toString()) - .openOn(map); -} - -// Listen for a click event on the Map element -map.on('click', onMapClick); diff --git a/web/routes/index.js b/web/routes/index.js index ffe1c21..3aaee01 100644 --- a/web/routes/index.js +++ b/web/routes/index.js @@ -47,13 +47,10 @@ router.get('/', function(req, res, next) { /* GET Map page. */ router.get('/map', function(req,res) { - // we can use the database to fetch a point, SELECT coordinates - Json.findOne({name: "points"}, 'coordinates', function(e,point){ - if (e) return e; - // send the view lat, and long. + // send the view lat, and long. city center res.render('map', { - lat : point.coordinates[1], - lng : point.coordinates[0] + lat : 43.654127, + lng : -79.383370 }); }); }); -- cgit v1.2.3 From fdb6e5c171da5ebaf91d09c84647d95ce4e530ca Mon Sep 17 00:00:00 2001 From: Kumar Damani Date: Tue, 26 Feb 2019 22:27:26 -0700 Subject: fixed spaces to indents --- web/public/javascripts/map.js | 12 +++++------- web/routes/index.js | 43 +++++++++++++++++++++---------------------- 2 files changed, 26 insertions(+), 29 deletions(-) diff --git a/web/public/javascripts/map.js b/web/public/javascripts/map.js index 414efee..d2afeb4 100644 --- a/web/public/javascripts/map.js +++ b/web/public/javascripts/map.js @@ -5,17 +5,15 @@ // different basemap L.tileLayer('https://stamen-tiles-{s}.a.ssl.fastly.net/toner-lite/{z}/{x}/{y}{r}.{ext}', { - attribution: 'Map tiles by Stamen Design, CC BY 3.0 — Map data © OpenStreetMap contributors', - subdomains: 'abcd', - minZoom: 0, - maxZoom: 13, - ext: 'png' + attribution: 'Map tiles by Stamen Design, CC BY 3.0 — Map data © OpenStreetMap contributors', + subdomains: 'abcd', + minZoom: 0, + maxZoom: 13, + 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("This is my city"); -// i can add regular html to this too - neat! myDataPoint.bindPopup("

City Hall (not really)

Toronto, ON
Information about city hall.

"); diff --git a/web/routes/index.js b/web/routes/index.js index 3aaee01..df579fc 100644 --- a/web/routes/index.js +++ b/web/routes/index.js @@ -7,32 +7,32 @@ var mongoose = require('mongoose'); var env = process.env.NODE_ENV || 'development'; var uri; if (env === 'development') { - uri = 'mongodb://localhost:27017/helpthehome' - // use for small testing only if really necessary - // uri = 'mongodb+srv://development:dreamteam@cluster0-krnr4.mongodb.net/helpthehome?retryWrites=true' + uri = 'mongodb://localhost:27017/helpthehome' + // use for small testing only if really necessary + // uri = 'mongodb+srv://development:dreamteam@cluster0-krnr4.mongodb.net/helpthehome?retryWrites=true' } else if (env === 'qa') { - uri = process.env.MONGODB_URI + uri = process.env.MONGODB_URI } else if (env === 'production') { - uri = '' + uri = '' } // Mongoose connection to MongoDB mongoose.connect(uri, { useNewUrlParser: true }, function (error) { - if (error) { - console.log(error); - console.log("App was not able to connect to the mongo server!"); - console.log("... double check that the mongo server is running locally"); - } else { + if (error) { + console.log(error); + console.log("App was not able to connect to the mongo server!"); + console.log("... double check that the mongo server is running locally"); + } else { console.log(`connected to ${uri}`); - } + } }); // Mongoose Schema definition var Schema = mongoose.Schema; var JsonSchema = new Schema({ - name: String, - type: Schema.Types.Mixed, - coordinates: Array + name: String, + type: Schema.Types.Mixed, + coordinates: Array }); // Mongoose Model definition @@ -40,19 +40,18 @@ var Json = mongoose.model('Jstring', JsonSchema, 'pointscollection'); /* GET home page. */ router.get('/', function(req, res, next) { - // for now just redirect to /map - //res.render('index', { title: 'Welcome' }); - res.redirect('/map'); + // for now just redirect to /map + //res.render('index', { title: 'Welcome' }); + res.redirect('/map'); }); /* GET Map page. */ router.get('/map', function(req,res) { // send the view lat, and long. city center - res.render('map', { - lat : 43.654127, - lng : -79.383370 - }); - }); + res.render('map', { + lat : 43.654127, + lng : -79.383370 + }); }); module.exports = router; -- cgit v1.2.3 From ecc0d9a1deb3cdaf272bbd6d87e76efa763e52d6 Mon Sep 17 00:00:00 2001 From: Kumar Damani Date: Tue, 26 Feb 2019 22:51:08 -0700 Subject: fixed default zoom level for map --- web/public/javascripts/map.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/web/public/javascripts/map.js b/web/public/javascripts/map.js index d2afeb4..5e5a303 100644 --- a/web/public/javascripts/map.js +++ b/web/public/javascripts/map.js @@ -8,7 +8,7 @@ L.tileLayer('https://stamen-tiles-{s}.a.ssl.fastly.net/toner-lite/{z}/{x}/{y}{r} attribution: 'Map tiles by Stamen Design, CC BY 3.0 — Map data © OpenStreetMap contributors', subdomains: 'abcd', minZoom: 0, - maxZoom: 13, + maxZoom: 18, ext: 'png' }).addTo(map); @@ -17,3 +17,5 @@ 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); -- cgit v1.2.3