Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

any reason this shouldn't work with leaflet-headless? #19

Closed
doapp-ryanp opened this issue Mar 8, 2016 · 3 comments
Closed

any reason this shouldn't work with leaflet-headless? #19

doapp-ryanp opened this issue Mar 8, 2016 · 3 comments

Comments

@doapp-ryanp
Copy link
Contributor

I have a geoJson file of a bunch of NWS alert zone polygons in it. I simply want to find what polygon (if any) a given lat/lng point is in. I want to do this entirely headless (no browser).

I'm using leaflet-headless and leaflet-pip to try and pull this off - but I keep getting a [TypeError: Expecting a function in instanceof check, but got undefined] error when I invoke leafletPip.pointInLayer().

Before I spend lots of time digging into the leaflet[-pip] code, was wondering if you knew off the top of your head why this would not work? Here is my code:

let Promise    = require('bluebird'),
    fs         = Promise.promisifyAll(require("fs")),
    srcDataDir = __dirname + '/../srcData',
    L          = require('leaflet-headless'),
    leafletPip = require('leaflet-pip');

module.exports.generate = function() {
  let rochesterMn = {
    lat: 44.0150757,
    lng: -92.4775256
  };

  return fs.readFileAsync(srcDataDir + '/simplifiedZones.geojson')
    .then(data => {
      var geoJSON = {};
      try {
        geoJSON = JSON.parse(data);
      } catch (err) {
        throw err;
      }

      let ugcZoneLayer = L.geoJson(geoJSON);

      let foundPoly = leafletPip.pointInLayer([rochesterMn.lng, rochesterMn.lat], ugcZoneLayer, true);

      console.log(foundPoly);
  });
};

thanks in advance. FWIW im on OSX

doapp-ryanp pushed a commit to doapp-ryanp/leaflet-pip that referenced this issue Mar 8, 2016
@doapp-ryanp
Copy link
Contributor Author

Sorry I got decided to dig in. Fix was straight forward. In Leafelet v1.0 there are no more Polygon classes

@tmcw
Copy link
Contributor

tmcw commented Mar 8, 2016

Closing in favor of #8

@tmcw tmcw closed this as completed Mar 8, 2016
@doapp-ryanp
Copy link
Contributor Author

Thanks. Is there a plan to get the change into a published module any time soon? Your module here is great but we can't use it as it sits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants