Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

186
Visualizações
How can I find all the coordinates in a Mapbox Draw circle using center and radius?

I have a Mapbox map and would like to get all the coordinates in an array of a circle that I custom drew using MapboxDraw.

This function takes the center of the circle, then by calculating the coordinates of the circle edges it decides which coordinates are in the circle and fills the array and then displayed via console log.

 <script>
           function CircleCoordinate(shape,shapeId)  {
            var Circlecoords = '';
            var standard = 0.00001;
            var center = shape.layer._latlng;
            var centerPointlng = center.lng;
            var centerPointlat = center.lat;
            var latPoint = centerPointlat;
            var lngPoint = centerPointlng;
            var radius = shape.layer._mRadius;
            
            for(var a = 0; a <= 360; a++)
            {
            
            var radiusPointlat = radius* Math.cos(a)+centerPointlat;
            var radiusPointlng = radius* Math.sin(a)+centerPointlng;
    
            for(var j = centerPointlng; j < radiusPointlng; j += standard)
              {
                //  console.log("radiusPointlat?????       ", radiusPointlat);
                 for(var i = centerPointlat;i < radiusPointlat; i += standard)
                {
                  // console.log("IS ITTTTT?????       ", isInside(centerPointlng, centerPointlat, radius, lngPoint, latPoint));
                if (isInside(centerPointlng, centerPointlat, radius, lngPoint, latPoint))
                {
                   Circlecoords +=  '('+latPoint + ',' + lngPoint + '),';
                }
                latPoint += standard;
              }
              lngPoint += standard;
              }
            }
    </script>

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Also take a look at the functions provided by http://turfjs.org/, which might be helpful, particularly http://turfjs.org/docs/#circle http://turfjs.org/docs/#pointGrid and http://turfjs.org/docs/#pointsWithinPolygon

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda