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

182
Vistas
how do create a geo location login system using Node.Js

I want to create a system where user can login only if the user is in a radius of the given location.
I am using node.js, express.js, MongoDB.
Can someone please guide me what packages/Services should I use and how do I approach this problem

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You have to make a boundary with geojson of your coverage area. To know your user location first of all get the user's current location with the device they use. store it in MongoDB. After getting the latitude or longitude of the user, use polygon-lookup npm package to identify the user is within your polygon radius or not.

If the user is in the location or not you can create a function like below -

    let geoJsonMapData =
    {
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [
              90.48509359359743,
              23.823275544984423
            ],
            [
              90.33422470092773,
              24.011030495565834
            ],
            [
              90.32435417175293,
              23.77529123645138
            ],
            [
              90.50283908843996,
              23.580546882813223
            ],
            [
              90.50519943237305,
              23.592031281422017
            ],
            [
              90.47208085656167,
              23.80909744710711
            ],
            [
              90.48509359359743,
              23.823275544984423
            ]
          ]
        ]
      }
    }
  ]
};
const check_in_radius_or_not = (longitude, latitude) =>{
            var lookup = new PolygonLookup( geoJsonMapData );
            var poly = lookup.search( longitude, latitude );
            
            if(poly){
                return 1;
            }else{
                return 0;
            }
        }

If the function returns 1 they will be within the radius and able to log in, else if return 0 they are not within the given boundary and not able to log in.

over 4 years ago · Santiago Trujillo 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