diff --git a/client/build/bundle.js b/client/build/bundle.js index 858bd1a..cf115a1 100644 --- a/client/build/bundle.js +++ b/client/build/bundle.js @@ -93,7 +93,9 @@ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { -eval("const BucketListView = __webpack_require__(/*! ./views/bucketListView.js */ \"./client/src/views/bucketListView.js\");\nconst CountryListView = __webpack_require__(/*! ./views/countryListView.js */ \"./client/src/views/countryListView.js\");\nconst Request = __webpack_require__(/*! ./services/request.js */ \"./client/src/services/request.js\");\n\nconst bucketListView = new BucketListView();\nconst countryListView = new CountryListView();\n\nconst countryRequest = new Request('https://restcountries.eu/rest/v2/all');\nconst bucketRequest = new Request('http://localhost:300/api/bucket_countries');\n\n\nconst getAllBucketListCountries = function(allCountries){\n for(country of allCountries){\n bucketListView.addCountry(country);\n }\n}\n\nconst appStart = function(){\n // request.get(getAllBucketListCountries);\n request.get(countryRequest);\n debugger;\n}\n\ndocument.addEventListener('DOMContentLoaded', appStart);\n\n\n//# sourceURL=webpack:///./client/src/app.js?"); + +eval("const BucketListView = __webpack_require__(/*! ./views/bucketListView.js */ \"./client/src/views/bucketListView.js\");\nconst CountryListView = __webpack_require__(/*! ./views/countryListView.js */ \"./client/src/views/countryListView.js\");\nconst Request = __webpack_require__(/*! ./services/request.js */ \"./client/src/services/request.js\");\nconst MapWrapper = __webpack_require__(/*! ./views/mapWrapper.js */ \"./client/src/views/mapWrapper.js\");\n\nconst bucketListView = new BucketListView();\nconst countryListView = new CountryListView();\n\nconst countryRequest = new Request('https://restcountries.eu/rest/v2/all');\nconst bucketRequest = new Request('http://localhost:3000/api/bucket_countries');\n\nallCountries = [];\n\nconst getAllBucketListCountries = function(allCountries){\n for(country of allCountries){\n bucketListView.render(country);\n const coords = [country.latlng[0], country.latlng[1]];\n\n mainMap.addMarker(coords, country);\n }\n}\n\n\n\nconst pullCountriesFromCountriesAPI = function(countriesAPI){\n for(country of countriesAPI){\n allCountries.push(country);\n }\n countryListView.showListOfCountries(allCountries);\n}\nconst handleSelected = function(countries){\n let selectTag = document.getElementById('countryDropDown');\n\n const country = allCountries[selectTag.value];\n bucketListView.addCountry(country);\n bucketRequest.post(country);\n\n const coords = [country.latlng[0], country.latlng[1]];\n\n mainMap.addMarker(coords, country);\n\n};\n\n\nconst handleDeleteAllCountriesButton = function(allCountries){\n bucketRequest.delete(deleteAllCountriesComplete);\n};\n\nconst deleteAllCountriesComplete = function(){\n bucketListView.clear();\n mainMap.clearLayer\n}\n\nconst handleResetMapZoomButton = function(){\n const coords = [55.857236, -3.166804];\n const zoom = 2;\n mainMap.moveMap(coords, zoom);\n}\n\n\nconst appStart = function(){\n console.log('Hello world!')\n bucketRequest.get(getAllBucketListCountries);\n countryRequest.get(pullCountriesFromCountriesAPI);\n\n const addCountryButton = document.getElementById('addCountry');\n addCountryButton.addEventListener('click', handleSelected);\n\n\n const deleteAllCountriesButton = document.querySelector('#deleteButton');\n deleteAllCountriesButton.addEventListener('click', handleDeleteAllCountriesButton);\n\n const resetMapZoomButton = document.querySelector('#resetmapzoom')\n resetMapZoomButton.addEventListener('click', handleResetMapZoomButton);\n\n\n const osmLayer = new L.TileLayer(\"http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png\")\n const containerID = \"mapContainer\";\n const coords = [55.857236, -3.166804];\n const zoom = 2;\n\n mainMap = new MapWrapper(containerID, coords, zoom);\n //markers = mainMap.markerClusterGroup();\n //console.log(markers);\n\n}\n\ndocument.addEventListener('DOMContentLoaded', appStart);\n\n\n//# sourceURL=webpack:///./client/src/app.js?"); + /***/ }), @@ -104,7 +106,7 @@ eval("const BucketListView = __webpack_require__(/*! ./views/bucketListView.js * /*! no static exports found */ /***/ (function(module, exports) { -eval("const Request = function(url) {\n this.url = url;\n}\n\nRequest.prototype.get = function (callback) {\n const request = new XMLHttpRequest();\n request.open(\"GET\", this.url);\n request.addEventListener(\"load\", function(){\n if(this.status !== 200){\n return;\n }\n const responseBody = JSON.parse(this.responseText);\n callback(responseBody);\n });\n request.send();\n};\n\nRequest.prototype.post = function(callback, body){\n const request = new XMLHttpRequest();\n request.open(\"POST\", this.url);\n request.setRequestHeader(\"Content-Type\", \"application/json\");\n request.addEventListener(\"load\", function(){\n if(this.status !== 201){\n return;\n }\n const responseBody = JSON.parse(this.responseText);\n callback(responseBody);\n });\n request.send(JSON.stringify(body));\n}\n\nRequest.prototype.delete = function(callback){\n const request = new XMLHttpRequest();\n request.open(\"DELETE\", this.url);\n request.addEventListener(\"load\", function(){\n if(this.status !== 204){\n return;\n }\n callback();\n })\n request.send();\n}\n\nmodule.exports = Request;\n\n\n//# sourceURL=webpack:///./client/src/services/request.js?"); +eval("const Request = function(url) {\n this.url = url;\n}\n\nRequest.prototype.get = function(callback) {\n const request = new XMLHttpRequest();\n request.open(\"GET\", this.url);\n request.addEventListener(\"load\", function(){\n if(this.status !== 200){\n return;\n }\n const responseBody = JSON.parse(this.responseText);\n callback(responseBody);\n });\n request.send();\n};\n\nRequest.prototype.post = function(body){\n const request = new XMLHttpRequest();\n request.open(\"POST\", this.url);\n request.setRequestHeader(\"Content-Type\", \"application/json\");\n request.addEventListener(\"load\", function(){\n if(this.status !== 201){\n return;\n }\n const responseBody = JSON.parse(this.responseText);\n // callback(responseBody);\n });\n request.send(JSON.stringify(body));\n}\n\nRequest.prototype.delete = function(callback){\n const request = new XMLHttpRequest();\n request.open(\"DELETE\", this.url);\n request.addEventListener(\"load\", function(){\n if(this.status !== 204){\n return;\n }\n callback();\n })\n request.send();\n}\n\nmodule.exports = Request;\n\n\n//# sourceURL=webpack:///./client/src/services/request.js?"); /***/ }), @@ -113,9 +115,9 @@ eval("const Request = function(url) {\n this.url = url;\n}\n\nRequest.prototype !*** ./client/src/views/bucketListView.js ***! \********************************************/ /*! no static exports found */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { -eval("var BucketListView = function(){\n this.bucketLists = [];\n}\n\nBucketListView.prototype.addCountry = function(country){\n this.bucketLists.push(country);\n this.render(country);\n}\n\nBucketListView.prototype.clear = function(){\n this.bucketLists = [];\n}\n\nBucketListView.prototype.render = function(country){\n const ul = document.querySelector('#countries');\n const li = document.createElement('li');\n li.innerText = country.name;\n ul.appendChild(li);\n}\n\n\nmodule.exports = BucketListView;\n\n\n//# sourceURL=webpack:///./client/src/views/bucketListView.js?"); +eval("const FurtherInfoView = __webpack_require__(/*! ./furtherInfoView.js */ \"./client/src/views/furtherInfoView.js\");\n\nvar BucketListView = function(){\n this.bucketLists = [];\n}\n\nBucketListView.prototype.addCountry = function(country){\n this.bucketLists.push(country);\n\n this.render(country);\n}\n\nBucketListView.prototype.clear = function(country) {\n this.bucketLists = [];\n const ul = document.querySelector('#countries');\n ul.innerHTML = '';\n}\n\nBucketListView.prototype.render = function(country){\n const ul = document.querySelector('#countries');\n const li = document.createElement('li');\n li.id = 'country_name'\n li.innerText = country.name;\n ul.appendChild(li);\n li.addEventListener('click', function(){\n console.log(\"country has been clicked\");\n let furtherInfo = new FurtherInfoView();\n furtherInfo.clearContent();\n furtherInfo.render(country);\n\n const coords = [country.latlng[0], country.latlng[1]];\n const zoom = 6;\n mainMap.moveMap(coords, zoom);\n });\n\n}\n\n\nmodule.exports = BucketListView;\n\n\n//# sourceURL=webpack:///./client/src/views/bucketListView.js?"); /***/ }), @@ -126,7 +128,29 @@ eval("var BucketListView = function(){\n this.bucketLists = [];\n}\n\nBucketLis /*! no static exports found */ /***/ (function(module, exports) { -eval("var countryListView = function(){\n this.countries = [];\n}\n\ncountryListView.prototype.showListOfCountries = function(countries){\n console.log(countries);\n\n let selectTag = document.getElementById('countriesDropDown');\n\n countries.forEach(function(country, index){\n let option = document.createElement('option');\n option.value = index;\n option.innerText = country.name;\n selectTag.appendChild(option);\n });\n};\n\n\n//Copy to app.js\n// countryListView.prototype.handleSelected = function(countries){\n// let selectTag = document.getElementById('countriesDropDown');\n// selectTag.addEventListener('change', function(){\n// const country = countries[this.value];\n// console.log(country);\n// bucketLists.render(country);\n//\n// const coords = [country.latlng[0], country.latlng[1]];\n// map.addMarker(coords);\n// });\n// };\n\nmodule.exports = countryListView;\n\n\n//# sourceURL=webpack:///./client/src/views/countryListView.js?"); +eval("var countryListView = function(){\n this.countries = [];\n}\n\ncountryListView.prototype.showListOfCountries = function(countries){\n console.log(countries);\n\n let selectTag = document.getElementById('countryDropDown');\n\n countries.forEach(function(country, index){\n let option = document.createElement('option');\n option.value = index;\n option.innerText = country.name;\n selectTag.appendChild(option);\n });\n};\n\n\n//Copy to app.js\n// countryListView.prototype.handleSelected = function(countries){\n// let selectTag = document.getElementById('countriesDropDown');\n// selectTag.addEventListener('change', function(){\n// const country = countries[this.value];\n// console.log(country);\n// bucketLists.render(country);\n//\n// const coords = [country.latlng[0], country.latlng[1]];\n// map.addMarker(coords);\n// });\n// };\n\nmodule.exports = countryListView;\n\n\n//# sourceURL=webpack:///./client/src/views/countryListView.js?"); + +/***/ }), + +/***/ "./client/src/views/furtherInfoView.js": +/*!*********************************************!*\ + !*** ./client/src/views/furtherInfoView.js ***! + \*********************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("var FurtherInfoView = function(){\n this.country = [];\n}\n\nFurtherInfoView.prototype.clearContent = function(){\n let divTag = document.querySelector('#furtherInfo');\n while (divTag.hasChildNodes()){\n divTag.removeChild(divTag.lastChild);\n }\n}\n\nFurtherInfoView.prototype.render = function(country){\n let divTag = document.querySelector('#furtherInfo');\n let header = document.createElement('p');\n header.innerText = 'Country Info:';\n divTag.appendChild(header);\n const ul = document.createElement('ul');\n const name = document.createElement('li');\n name.innerText = `Name: ${country.name}`;\n ul.appendChild(name);\n const capital = document.createElement('li');\n capital.innerText = `Capital: ${country.capital}`;\n ul.appendChild(capital);\n const language = document.createElement('li');\n language.innerText = `Main Language: ${country.languages[0].name}`;\n ul.appendChild(language);\n const pop = document.createElement('li');\n pop.innerText = `Population: ${country.population}`;\n ul.appendChild(pop);\n divTag.appendChild(ul);\n}\n\nmodule.exports = FurtherInfoView;\n\n\n//# sourceURL=webpack:///./client/src/views/furtherInfoView.js?"); + +/***/ }), + +/***/ "./client/src/views/mapWrapper.js": +/*!****************************************!*\ + !*** ./client/src/views/mapWrapper.js ***! + \****************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("const MapWrapper = function(containerID, coords, zoom) {\n const osmLayer = new L.tileLayer('https://stamen-tiles-{s}.a.ssl.fastly.net/watercolor/{z}/{x}/{y}.{ext}', {\n\tattribution: 'Map tiles by Stamen Design, CC BY 3.0 — Map data © OpenStreetMap',\n\tsubdomains: 'abcd',\n\tminZoom: 2,\n\tmaxZoom: 15,\n\text: 'png'\n});\n this.map = L.map(containerID).addLayer(osmLayer).setView(coords, zoom);\n}\n\n// MapWrapper.prototype.currentLocation = function (coords) {\n// this.map.setView(coords);\n// };\n\nMapWrapper.prototype.moveMap = function (coords, zoom) {\n this.map.flyTo(coords, zoom);\n};\n\nMapWrapper.prototype.addMarker = function(coords, country){\n L.marker(coords).addTo(this.map).bindPopup(country.name);\n}\n\nmodule.exports = MapWrapper;\n\n\n//# sourceURL=webpack:///./client/src/views/mapWrapper.js?"); /***/ }) diff --git a/client/build/index.html b/client/build/index.html index 7100858..ff04a3d 100644 --- a/client/build/index.html +++ b/client/build/index.html @@ -3,36 +3,45 @@ Countries Project + + + - -

Bucketlist

-
-

- Select a country to add to your Bucketlist: -

- - -
+

Bucket List

+
-
-

- Countries you wish to visit: -

- + +
+
+

+ Please select a country to add to your Bucketlist! +

+ + +
-
+
+ +
+ +
+

Countries List:

+
    +
    +
    +

    Country Info:

    +
    + + +

    Created by Angelina Blyth, Roddy Daly and Peter Whittle.

    diff --git a/client/build/styles.css b/client/build/styles.css index 717a79a..d43f478 100644 --- a/client/build/styles.css +++ b/client/build/styles.css @@ -1,5 +1,151 @@ +*{ + /* not sure if this messes up the margin for the map? */ + margin: 0; +} + +header{ + background-color: #276FBF; + font-size: 25px; + text-align: center; + color: #F6F4F3; + font-family: 'Amatic SC', cursive; +} + +body{ + background-color: #F6F4F3; + color: #183059; + font-family: 'Josefin Sans', sans-serif; +} + +footer{ + text-align: center; + font-family: 'Josefin Sans', sans-serif; + position: fixed; + z-index: 1; + width: 100%; + bottom: 0; + background-color: #276FBF; + color: #FFFFFF; + opacity: 0.8 +} + +ul{ + padding-left: 0; + padding-bottom: 20px; + list-style: none; +} + +button{ + padding-top: 5px; + border: none; + font: inherit; + color: inherit; + background-color: transparent; + cursor: pointer; + border-radius: 3px; +} + +button:hover{ + padding-top: 5px; + border: none; + font: inherit; + color: inherit; + transition: background-color 500ms; + background-color: #2B7CD8; + cursor: pointer; +} + +p{ + font-weight: bold; + padding-top: 15px; + padding-bottom: 15px; +} + +#resetmapzoom{ + margin-left: 15px; +} + +#deleteButton:hover{ + padding-top: 5px; + border: none; + font: inherit; + color: inherit; + transition: background-color 500ms; + background-color: #F03A47; + cursor: pointer; + border-radius: 3px; +} + +#countryListContainer{ + display: flex; + justify-content: center; +} + +#countryList{ + padding-top: 20px; + text-align: center; + max-width: 375px; + vertical-align: middle; +} + +#countryDropDown{ + margin: 10px; +} + +#country_name{ + cursor: pointer; + padding: 5px; +} + +#country_name:hover{ + cursor: pointer; + padding: 5px; + transition: background-color 500ms; + background-color: #2B7CD8; + border-radius: 3px; +} + +#infoPane{ + display: flex; + justify-content: center; +} + #mapContainer { height: 400px; width: auto; - margin-bottom: 2.5%; + margin-top: 15px; + margin-left: 15px; + margin-right: 15px; +} + +#bucketListHeader { +font-weight: bold; +padding-top: 15px; +padding-bottom: 15px; +} + +#bucketListContainer{ + text-align: center; + margin: 15px; + margin-bottom: 40px; + height: 300px; + width: 400px; + overflow: scroll; + background-color: #EFEEED; +} + +#countryInfoHeader{ +font-weight: bold; +padding-top: 15px; +padding-bottom: 15px; +} + +#furtherInfo{ + text-align: center; + margin: 15px; + margin-bottom: 40px; + height: 300px; + width: 400px; + overflow: scroll; + background-color: #EFEEED; } diff --git a/client/src/app.js b/client/src/app.js index d60136c..de59c9e 100644 --- a/client/src/app.js +++ b/client/src/app.js @@ -1,21 +1,90 @@ const BucketListView = require('./views/bucketListView.js'); const CountryListView = require('./views/countryListView.js'); const Request = require('./services/request.js'); +const MapWrapper = require('./views/mapWrapper.js'); const bucketListView = new BucketListView(); const countryListView = new CountryListView(); const countryRequest = new Request('https://restcountries.eu/rest/v2/all'); -const bucketRequest = new Request('http://localhost:300/api/bucket_countries'); +const bucketRequest = new Request('http://localhost:3000/api/bucket_countries'); +allCountries = []; const getAllBucketListCountries = function(allCountries){ for(country of allCountries){ - bucketListView.addCountry(country); + bucketListView.render(country); + const coords = [country.latlng[0], country.latlng[1]]; + + mainMap.addMarker(coords, country); } } + + +const pullCountriesFromCountriesAPI = function(countriesAPI){ + for(country of countriesAPI){ + allCountries.push(country); + } + countryListView.showListOfCountries(allCountries); +} +const handleSelected = function(countries){ + let selectTag = document.getElementById('countryDropDown'); + + const country = allCountries[selectTag.value]; + bucketListView.addCountry(country); + bucketRequest.post(country); + + const coords = [country.latlng[0], country.latlng[1]]; + + mainMap.addMarker(coords, country); + +}; + + +const handleDeleteAllCountriesButton = function(allCountries){ + bucketRequest.delete(deleteAllCountriesComplete); +}; + +const deleteAllCountriesComplete = function(){ + bucketListView.clear(); + mainMap.clearLayer +} + +const handleResetMapZoomButton = function(){ + const coords = [55.857236, -3.166804]; + const zoom = 2; + mainMap.moveMap(coords, zoom); +} + + const appStart = function(){ + + console.log('Hello world!') + bucketRequest.get(getAllBucketListCountries); + countryRequest.get(pullCountriesFromCountriesAPI); + + const addCountryButton = document.getElementById('addCountry'); + addCountryButton.addEventListener('click', handleSelected); + + + const deleteAllCountriesButton = document.querySelector('#deleteButton'); + deleteAllCountriesButton.addEventListener('click', handleDeleteAllCountriesButton); + + const resetMapZoomButton = document.querySelector('#resetmapzoom') + resetMapZoomButton.addEventListener('click', handleResetMapZoomButton); + + + const osmLayer = new L.TileLayer("http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png") + const containerID = "mapContainer"; + const coords = [55.857236, -3.166804]; + const zoom = 2; + + mainMap = new MapWrapper(containerID, coords, zoom); + //markers = mainMap.markerClusterGroup(); + //console.log(markers); + + // request.get(getAllBucketListCountries); request.get(countryRequest); debugger; diff --git a/client/src/services/request.js b/client/src/services/request.js index 8615b10..59e7f89 100644 --- a/client/src/services/request.js +++ b/client/src/services/request.js @@ -2,7 +2,7 @@ const Request = function(url) { this.url = url; } -Request.prototype.get = function (callback) { +Request.prototype.get = function(callback) { const request = new XMLHttpRequest(); request.open("GET", this.url); request.addEventListener("load", function(){ @@ -15,7 +15,7 @@ Request.prototype.get = function (callback) { request.send(); }; -Request.prototype.post = function(callback, body){ +Request.prototype.post = function(body){ const request = new XMLHttpRequest(); request.open("POST", this.url); request.setRequestHeader("Content-Type", "application/json"); @@ -24,7 +24,7 @@ Request.prototype.post = function(callback, body){ return; } const responseBody = JSON.parse(this.responseText); - callback(responseBody); + // callback(responseBody); }); request.send(JSON.stringify(body)); } diff --git a/client/src/views/bucketListView.js b/client/src/views/bucketListView.js index 1c1c23c..dc88634 100644 --- a/client/src/views/bucketListView.js +++ b/client/src/views/bucketListView.js @@ -1,21 +1,38 @@ +const FurtherInfoView = require('./furtherInfoView.js'); + var BucketListView = function(){ this.bucketLists = []; } BucketListView.prototype.addCountry = function(country){ this.bucketLists.push(country); + this.render(country); } -BucketListView.prototype.clear = function(){ +BucketListView.prototype.clear = function(country) { this.bucketLists = []; + const ul = document.querySelector('#countries'); + ul.innerHTML = ''; } BucketListView.prototype.render = function(country){ const ul = document.querySelector('#countries'); const li = document.createElement('li'); + li.id = 'country_name' li.innerText = country.name; ul.appendChild(li); + li.addEventListener('click', function(){ + console.log("country has been clicked"); + let furtherInfo = new FurtherInfoView(); + furtherInfo.clearContent(); + furtherInfo.render(country); + + const coords = [country.latlng[0], country.latlng[1]]; + const zoom = 6; + mainMap.moveMap(coords, zoom); + }); + } diff --git a/client/src/views/countryListView.js b/client/src/views/countryListView.js index 138f932..12fc843 100644 --- a/client/src/views/countryListView.js +++ b/client/src/views/countryListView.js @@ -5,7 +5,7 @@ var countryListView = function(){ countryListView.prototype.showListOfCountries = function(countries){ console.log(countries); - let selectTag = document.getElementById('countriesDropDown'); + let selectTag = document.getElementById('countryDropDown'); countries.forEach(function(country, index){ let option = document.createElement('option'); diff --git a/client/src/views/furtherInfoView.js b/client/src/views/furtherInfoView.js new file mode 100644 index 0000000..443784e --- /dev/null +++ b/client/src/views/furtherInfoView.js @@ -0,0 +1,33 @@ +var FurtherInfoView = function(){ + this.country = []; +} + +FurtherInfoView.prototype.clearContent = function(){ + let divTag = document.querySelector('#furtherInfo'); + while (divTag.hasChildNodes()){ + divTag.removeChild(divTag.lastChild); + } +} + +FurtherInfoView.prototype.render = function(country){ + let divTag = document.querySelector('#furtherInfo'); + let header = document.createElement('p'); + header.innerText = 'Country Info:'; + divTag.appendChild(header); + const ul = document.createElement('ul'); + const name = document.createElement('li'); + name.innerText = `Name: ${country.name}`; + ul.appendChild(name); + const capital = document.createElement('li'); + capital.innerText = `Capital: ${country.capital}`; + ul.appendChild(capital); + const language = document.createElement('li'); + language.innerText = `Main Language: ${country.languages[0].name}`; + ul.appendChild(language); + const pop = document.createElement('li'); + pop.innerText = `Population: ${country.population}`; + ul.appendChild(pop); + divTag.appendChild(ul); +} + +module.exports = FurtherInfoView; diff --git a/client/src/views/mapWrapper.js b/client/src/views/mapWrapper.js index f1aacf5..9de0dcf 100644 --- a/client/src/views/mapWrapper.js +++ b/client/src/views/mapWrapper.js @@ -1,16 +1,24 @@ const MapWrapper = function(containerID, coords, zoom) { - const osmLayer = new L.TileLayer("http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"); - this.map = L.map(containerID).setView(coords, zoom).addLayer(osmLayer); + const osmLayer = new L.tileLayer('https://stamen-tiles-{s}.a.ssl.fastly.net/watercolor/{z}/{x}/{y}.{ext}', { + attribution: 'Map tiles by Stamen Design, CC BY 3.0 — Map data © OpenStreetMap', + subdomains: 'abcd', + minZoom: 2, + maxZoom: 15, + ext: 'png' +}); + this.map = L.map(containerID).addLayer(osmLayer).setView(coords, zoom); } -MapWrapper.prototype.currentLocation = function (coords) { - this.map.setView(coords); -}; +// MapWrapper.prototype.currentLocation = function (coords) { +// this.map.setView(coords); +// }; -MapWrapper.prototype.moveMap = function (coords) { - this.map.flyTo(coords); +MapWrapper.prototype.moveMap = function (coords, zoom) { + this.map.flyTo(coords, zoom); }; -MapWrapper.prototype.addMarker = function(coords){ - L.marker(coords).addTo(this.map); +MapWrapper.prototype.addMarker = function(coords, country){ + L.marker(coords).addTo(this.map).bindPopup(country.name); } + +module.exports = MapWrapper; diff --git a/db/seed.js b/db/seed.js new file mode 100644 index 0000000..7c7a6c1 --- /dev/null +++ b/db/seed.js @@ -0,0 +1,58 @@ +use bucketdb; + +db.bucket_countries.insert([ + { + name: 'Afghanistan', + capital: 'Kabul', + currency: 'Afghan afghani', + flag: 'https://restcountries.eu/data/afg.svg' + }, + { + name: 'Albania', + capital: 'Tirana', + currency: 'Albanian lek', + flag: 'https://restcountries.eu/data/alb.svg' + }, + { + name: 'Czech Republic', + capital: 'Prague', + currency: 'Czech koruna', + flag: 'https://restcountries.eu/data/cze.svg' + }, + { + name: 'Eritrea', + capital: 'Asmara', + currency: 'Eritrean nakfa', + flag: 'https://restcountries.eu/data/eri.svg' + }, + { + name: 'Holy See', + capital: 'Rome', + currency: 'Euro', + flag: 'https://restcountries.eu/data/vat.svg' + }, + { + name: 'India', + capital: 'New Delhi', + currency: 'Indian rupee', + flag: 'https://restcountries.eu/data/ind.svg' + }, + { + name: 'Iran', + capital: 'Tehran', + currency: 'Iranian rial', + flag: 'https://restcountries.eu/data/irn.svg' + }, + { + name: 'Isle of Man', + capital: 'Douglas', + currency: 'British pound', + flag: 'https://restcountries.eu/data/imn.svg' + }, + { + name: 'Jamaica', + capital: 'Kingston', + currency: 'Jamaican dollar', + flag: 'https://restcountries.eu/data/jam.svg' + } +])