1

I've got a point dataset (~ 160.000 points) which has a filesize of around 30 MB. Because that is too large I decided to slit it into 12 separate GeoJSON files. I've got a map with 12 polygons. When the user will select one polygon I want the related GeoJSON point file to be downloaded and displayed on the map. Therefore I am loading the point data script dynamically:

    function onclick(e) {
        map.fitBounds(e.target.getBounds()); // Zoom to Polygon
        var head = document.getElementsByTagName('head')[0];
        var script= document.createElement('script');
        script.type= 'text/javascript';
        var data = feature.properties.name; // getting the name of the selected polygon, point data is namend by polygon
        var datafile = '.js';
        script.src= data + datafile;
        head.appendChild(script);
        pointToLayer: marker_icon;
        map.addLayer(data);
    };

As I found out with the inspector of my webbrowser, the point data file will be loaded successfully, but the points are not getting into the map. The datafile looks like that:

var data = {type:"FeatureCollection", features: [
{ type: "Feature", properties: { LN: "412C-6351", AH: 33.94, BA: "1958\/03\/01", BE: "1899\/12\/31", BV: "UN"  }, geometry: { type: "Point", coordinates: [ 13.46311, 52.46391 ] } }]};

How can I fix this?

  • 1
    What is line pointToLayer: marker_icon; supposed to do? It looks like invalid syntax. – TomazicM Sep 16 at 13:23
  • It's calling this function: function marker_icon(feature, latlng) { return L.circleMarker(latlng, { radius: 8.0, fillColor: getColor(feature.properties.ET), color: getColor(feature.properties.ET), weight: 1, opacity: 1.0, fillOpacity: 0.75 }) } – Jones Sep 17 at 10:50
  • I admit I'm not familiar with this syntax. Where does it come from? And how are then and from where parameters feature and latlng passed to the function call? – TomazicM Sep 17 at 12:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.