1

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"]]';

Code 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); 
1

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.