Leaflet map with Socrata open data with lat/lng in a combined geom point column?

83 views Asked by At

I learned how to create a Leaflet map with Socrata open data when latitude and longitude appear in separate columns. See working examples at https://github.com/JackDougherty/leaflet-socrata

My problem: how to make this work when latitude and longitude are combined in one point data field (geom) inside Socrata? This is common for datasets published on http://data.hartford.gov. See my non-working example at https://github.com/JackDougherty/leaflet-socrata

Solved with this code snippet:

// load open data from Socrata endpoint in GeoJSON format
// Food Establishments, City of Hartford Open Data https://data.hartford.gov/resource/daux-ukcc
$.getJSON("https://data.hartford.gov/resource/daux-ukcc.geojson", function (data){
    var geoJsonLayer = L.geoJson(data, {
        pointToLayer: function( feature, latlng) {
            var marker = L.marker(latlng);
            marker.bindPopup(feature.properties.blms_dba); // replace last term with property data labels to display from GeoJSON file
            return marker;
        }
    }).addTo(map);
});

See my notes and more examples at https://www.datavizforall.org/leaflet/with-socrata/

0

There are 0 answers