So I was wondering how I can get the points from the GeoJSON located here.

and then for each of them separately check if the distance of Markers is within 5 meters range of these. I have tried but not being able to call points from the GeoJSON and I'm wondering how I would get it to be specific for each of the Markers. So that the if statement return if any of the Markers from the GeoJSON is within 5 Meters of the "Hydrat" Markers below.

 var hydrat1 = [56.41083875205333, 8.864636421203615];
 var hydrat2 = [56.41069629842804, 8.868584632873537];
 var hydrat3 = [56.40941419180167, 8.866181373596193];

Here is the complete code I'm trying to use

function requestGeoJson(){
      .then(function(response){ return response.json() })
        // var http = new XMLHttpRequest();
        // var url = "https://maker.ifttt.com/trigger/vandingsmaskine/with/key/";
          //http.open("POST", url, true);
          //http.send(JSON.stringify({"value1": "ID 1"}));
          var hydrat1 = [56.41083875205333, 8.864636421203615];
          var hydrat2 = [56.41069629842804, 8.868584632873537];
          var hydrat3 = [56.40941419180167, 8.866181373596193];

         setTimeout(requestGeoJson, 5000);

  • 1
    You can use turf.js – neogeomat Aug 7 at 4:35
  • what? @neogeomat – daniel pedersen Aug 7 at 11:18
  • don't know how to use that?. how am i going to do it using turf – daniel pedersen Aug 7 at 12:14
  • @neogeomat How would I use that for my use case don't really know – daniel pedersen Aug 8 at 7:30

Maybe this a will help a little. I have an example where you click on a map and it gets the points within 150 miles of your click. I also used a URL with JQuery's getJSON function.

If your data is on another site you usually get a CORS error, but if it doesn't change(static), go to the data site copy/paste into notepad and save it as a json file, than place it in the same folder as your HTML file and you will avoid the error.

http://www.gistechsolutions.com/leaflet/DEMO/Select/SelectPoints3.html or this one has a write up and working link. http://www.gistechsolutions.com/leaflet/DEMO/Select/SelectPoints4Explained.html

I didn't need turf for these. My examples used miles but radius is really meters. If you don't want to start off a mouse click, you have the coordinates of the three markers, just pass them one at a time in a loop.

  • Can't really figure out how to use that for my specific use case since I'm getting the GeoJSON from a URL @Bill Chappell – daniel pedersen Aug 7 at 13:51
  • $.getJSON can get the data from the url, or a file unless your getting a CORS error. If the data is on someone else's server, you're are probably going to get a CORS error. Hit F12 and check the console for the error message. – Bill Chappell Aug 7 at 14:57
  • Checked the URL you are using and the coordinates are a string not number. ex ["8.91894","56.4098"] Use geojsonlint.com to see if the data you are looking at is good. – Bill Chappell Aug 7 at 15:26
  • I'm not so intelligent so want to know how I can do what I described in the original post – daniel pedersen Aug 7 at 16:19
  • what would i have todo? – daniel pedersen Aug 7 at 18:33

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.