Draw several lines to represent the distance to a certain point for several points

by CoderCoder42   Last Updated October 19, 2019 09:22 AM - source

It gives a certain point that I want to analyze.

I want to see what is the distance of that point from the rest of the x points on the openlayers map ...

The data comes from external json in the form of coordinates:

[["47.483963","22.718147"],["47.487193","22.713881"],["47.490545","22.709374"],["47.494269","22.704444"],["47.497467","22.700157"],["47.497467","22.700157"],["47.497467","22.700157"],["47.497467","22.700157"],["47.497467","22.700157"],["47.512619","22.679901"],["47.516006","22.675438"],["47.520897","22.66888"],["47.520897","22.66888"],["47.520897","22.66888"],["47.5303","22.656273"],["47.5303","22.656273"],["47.5384","22.645428"],["47.541799","22.640921"],["47.54515","22.636414"],["47.548549","22.631906"],["47.549899","22.630075"],["47.549899","22.630075"],["47.549899","22.630075"],["47.549899","22.630075"],["47.549899","22.630075"],["47.567917","22.605949"],["47.571304","22.601418"],["47.571304","22.601418"],["47.57634","22.59462"],["47.57634","22.59462"],["47.585651","22.582186"],["47.589375","22.577186"],["47.592545","22.572922"],["47.592545","22.572922"],["47.592545","22.572922"],["47.592545","22.572922"],["47.592545","22.572922"],["47.592545","22.572922"],["47.592545","22.572922"],["47.592545","22.572922"],["47.592545","22.572922"],["47.592545","22.572922"],["47.592545","22.572922"],["47.592545","22.572922"],["47.592545","22.572922"],["47.592545","22.572922"],["47.592545","22.572922"],["47.592545","22.572922"],["47.592545","22.572922"],["47.592545","22.572922"],["47.592545","22.572922"],["47.592545","22.572922"],["47.592545","22.572922"],["47.592545","22.572922"],["47.592545","22.572922"],["47.592545","22.572922"],["47.592545","22.572922"],["47.592545","22.572922"],["47.592545","22.572922"],["47.592545","22.572922"],["47.592545","22.572922"],["47.592545","22.572922"],["47.592545","22.572922"],["47.592545","22.572922"],["47.592545","22.572922"],["47.592545","22.572922"],["47.592545","22.572922"]]';

Cod is here:

 function hex() {
          $.post("data_source.php", {
            get_data: 1
            }, function(result){
                //console.log(result);      
                //var data = JSON.parse(result);
                for(var i = 0; i < result.length; i++){
                        add_map_point(result[i][0],result[i][1]);
                }
           });

        }


        function add_map_point(lat, lng) {

          var vectorLayer = new ol.layer.Vector({
            source:new ol.source.Vector({
              features: [new ol.Feature({
                    geometry: new ol.geom.Point(ol.proj.transform([parseFloat(lng), parseFloat(lat)], 'EPSG:4326', 'EPSG:3857')),
                })]
            }),
            style: new ol.style.Style({
              image: new ol.style.Icon({
                anchor: [0.5, 0.5],
                anchorXUnits: "fraction",
                anchorYUnits: "fraction",
                src: "https://upload.wikimedia.org/wikipedia/commons/e/ec/RedDot.svg"
              })
            })
          });



          map.addLayer(vectorLayer); 


Related Questions


JSON coordinates not showing on Open Layers 3

Updated May 17, 2015 21:09 PM

Find closest feature

Updated March 16, 2017 17:22 PM

How to show label of a new feature layer in OpenLayers?

Updated December 01, 2016 08:09 AM