Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

184
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda