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 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 Respostas
Responde à pergunta

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 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