Skip to main content
deleted 34 characters in body
Source Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

I am working on a school project that tracks the location of someone via an Arduino GPS tracker. The issue I am running into is trying to convert JSON data into GeoJSON data. When the console is opened the error presented is invalid GeoJSON object. I have seen posts here describing the process to convert the data, but due to my rudimentary understanding of coding I am not sure how to implement this conversion into code. The code is based on this: https://github.com/perliedman/leaflet-realtime

index.js

var map = L.map('map');
    realtime = L.realtime({
        url: 'https://data.sparkfun.com/output/3J0bK7jKYvs6OL6V5zZE.json',
        jsonp: 'callback',
        cache: true,
        crossOrigin: true,
        type: 'GET',
    },
    {
        interval: 10 * 1000
    }).addTo(map);

L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
    attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);

realtime.on('update', function() {
    map.fitBounds(realtime.getBounds(), {maxZoom: 3});
});

The url https://data.sparkfun.com/output/3J0bK7jKYvs6OL6V5zZE.json describes the provided JSON data from my Arduino, but in order for the code to work it seems the data needs to be in GeoJSON format.

Thanks for any and all help!

I am working on a school project that tracks the location of someone via an Arduino GPS tracker. The issue I am running into is trying to convert JSON data into GeoJSON data. When the console is opened the error presented is invalid GeoJSON object. I have seen posts here describing the process to convert the data, but due to my rudimentary understanding of coding I am not sure how to implement this conversion into code. The code is based on this: https://github.com/perliedman/leaflet-realtime

index.js

var map = L.map('map');
    realtime = L.realtime({
        url: 'https://data.sparkfun.com/output/3J0bK7jKYvs6OL6V5zZE.json',
        jsonp: 'callback',
        cache: true,
        crossOrigin: true,
        type: 'GET',
    },
    {
        interval: 10 * 1000
    }).addTo(map);

L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
    attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);

realtime.on('update', function() {
    map.fitBounds(realtime.getBounds(), {maxZoom: 3});
});

The url https://data.sparkfun.com/output/3J0bK7jKYvs6OL6V5zZE.json describes the provided JSON data from my Arduino, but in order for the code to work it seems the data needs to be in GeoJSON format.

Thanks for any and all help!

I am working on a school project that tracks the location of someone via an Arduino GPS tracker. The issue I am running into is trying to convert JSON data into GeoJSON data. When the console is opened the error presented is invalid GeoJSON object. I have seen posts here describing the process to convert the data, but due to my rudimentary understanding of coding I am not sure how to implement this conversion into code. The code is based on this: https://github.com/perliedman/leaflet-realtime

index.js

var map = L.map('map');
    realtime = L.realtime({
        url: 'https://data.sparkfun.com/output/3J0bK7jKYvs6OL6V5zZE.json',
        jsonp: 'callback',
        cache: true,
        crossOrigin: true,
        type: 'GET',
    },
    {
        interval: 10 * 1000
    }).addTo(map);

L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
    attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);

realtime.on('update', function() {
    map.fitBounds(realtime.getBounds(), {maxZoom: 3});
});

The url https://data.sparkfun.com/output/3J0bK7jKYvs6OL6V5zZE.json describes the provided JSON data from my Arduino, but in order for the code to work it seems the data needs to be in GeoJSON format.

edited title
Link
ahmadhanb
  • 41.4k
  • 5
  • 54
  • 109

converting Converting JSON data to GeoJSON data from an Arduino GPS tracker

Source Link

converting JSON data to GeoJSON data from an Arduino GPS tracker

I am working on a school project that tracks the location of someone via an Arduino GPS tracker. The issue I am running into is trying to convert JSON data into GeoJSON data. When the console is opened the error presented is invalid GeoJSON object. I have seen posts here describing the process to convert the data, but due to my rudimentary understanding of coding I am not sure how to implement this conversion into code. The code is based on this: https://github.com/perliedman/leaflet-realtime

index.js

var map = L.map('map');
    realtime = L.realtime({
        url: 'https://data.sparkfun.com/output/3J0bK7jKYvs6OL6V5zZE.json',
        jsonp: 'callback',
        cache: true,
        crossOrigin: true,
        type: 'GET',
    },
    {
        interval: 10 * 1000
    }).addTo(map);

L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
    attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);

realtime.on('update', function() {
    map.fitBounds(realtime.getBounds(), {maxZoom: 3});
});

The url https://data.sparkfun.com/output/3J0bK7jKYvs6OL6V5zZE.json describes the provided JSON data from my Arduino, but in order for the code to work it seems the data needs to be in GeoJSON format.

Thanks for any and all help!