question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Get GeoJson File as Object

See original GitHub issue

Dear Team,

Loved to use use your package so far. I found myself with a GeoJson problem.

I use a regular form to upload a GeoJson file. No big deal. Problem is to get this file and use it to generate the map on Leaflet.

Template.mapDropdown.events({
    "change #mapFilesDropDown": function(event, template){
         event.preventDefault();
         console.log(event.target.value);
         var mapId = event.target.value;
         var myMap = Maps.findOne(mapId);
         console.log(myMap.path);
    }
});

This event get the File _id to return the selected GeoJson file. MyMap.path gives me the absolute path (assets/app/uploads/Maps/dnHkQkceumTKmLGSR.geojson), but I cant reach it…

How do I get the GeoJson file as a Json Object?, and use this object to generate my leaflet map? (this one is on me 😄 )

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
fillipefeitosacommented, Dec 20, 2018

I solved by setting a downloadRoute


export const Maps = new FilesCollection({
    collectionName: 'Maps',
    allowClientCode: true,
    downloadRoute: '/public/',

    onBeforeUpload(file){
        if(file.size <= 10485760 && /json|geojson/i.test(file.extension)){
            return true;
        }
        return 'Favor fazer upload de geojson válido';
    }
});

Thanks for your time and great work,

1reaction
fillipefeitosacommented, Dec 19, 2018

Thanks for the fast response!!

.link() gave me:

http://localhost:3000/cdn/storage/Maps/dnHkQkceumTKmLGSR/original/dnHkQkceumTKmLGSR.geojson

I am on development env. Am I supposed to use that on production? Thanks again

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to create JSON file from GeoJSON - GIS Stack Exchange
You can save GeoJSON data to a file with a .json extension. You can also encode the GeoJSON data to get a string...
Read more >
How can I parse GeoJSON with Python - Stack Overflow
You can read it with json import, and file open: import json with open(path) as f: data = json.load(f) for feature in data['features']: ......
Read more >
Draw and Edit with GeoJson.io - Hands-On Data Visualization
GeoJson.io lets you create geospatial files from scratch by using simple drawing tools to place points, polylines, or polygons on the map. These...
Read more >
Using GeoJSON with Leaflet
A GeoJSON object may represent a region of space (a Geometry), a spatially bounded entity (a Feature), or a list of Features (a...
Read more >
GeoJSON—ArcGIS Online Help | Documentation
GeoJSON is an open standard geospatial data interchange format that represents simple geographic features and their nonspatial attributes.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found