diff --git a/js/geocsv.js b/js/geocsv.js index b7df3bf..1dfba8f 100644 --- a/js/geocsv.js +++ b/js/geocsv.js @@ -80,6 +80,12 @@ var GeoCSV = { * Methods related to locating and presenting data on the map */ GIS: { + /** + * the relative or absolute URL of the place where map pin images may be + * fetched from. + */ + iconUrlBase: "img/map-pins/", + /** * Return an appropriate pin image name for this `record`. */ @@ -124,13 +130,13 @@ var GeoCSV = { if ( !isNaN( lat) && !isNaN( lng)) { var pin = L.icon( {iconAnchor: [16, 41], iconSize: [32, 42], - iconUrl: "img/map-pins/" + + iconUrl: this.iconUrlBase + this.pinImage( record) + ".png", riseOnHover: true, shadowAnchor: [16, 23], shadowSize: [57, 24], - shadowUrl: "img/map-pins/shadow_pin.png"}); + shadowUrl: this.iconUrlBase + "shadow_pin.png"}); var marker = L.marker( L.latLng( lat, lng), {icon: pin, title: record["name"]}); marker.bindPopup( this.popupContent( record)); @@ -184,8 +190,6 @@ var GeoCSV = { view.fitBounds( [[ maxLat, maxLng], [ minLat, minLng]]); } - //return [ minLat + ( ( maxLat - minLat) / 2), - // minLng + ( ( maxLng - minLng) / 2)]; } }, @@ -315,5 +319,13 @@ var GeoCSV = { this.Notify.error( error); } } + }, + + /** + * Set the base address from which to serve icon (map pin) URLs to thia + * `iconUrlBase` value. + */ + setIconUrlBase( iconUrlBase) { + this.GIS.iconUrlBase = String( iconUrlBase); } } diff --git a/package.json b/package.json new file mode 100644 index 0000000..bd489a1 --- /dev/null +++ b/package.json @@ -0,0 +1,28 @@ +{ + "name": "@simon_brooke/geocsv", + "version": "1.0.0", + "description": "An ultra-lightweight tool to show comma-separated value data on a map.", + "main": "js/geocsv.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/simon-brooke/geocsv-js.git" + }, + "keywords": [ + "CSV", + "map", + "GIS" + ], + "author": "Simon Brooke", + "license": "GPL-2.0-or-later", + "bugs": { + "url": "https://github.com/simon-brooke/geocsv-js/issues" + }, + "homepage": "https://simon-brooke.github.io/geocsv-js/", + "dependencies": { + "leaflet": "^1.6.0", + "papaparse": "^5.1.1" + } +}