Armax/Pokemon-GO-node-api

Get NearbyPokemon expiration-time and position

Opened this issue · 4 comments

Hi,

how can i get the expiration-time and position of an pokemon in the nearby-list of a map-cell?

The only information i get are DistanceMeters (all time null), EncounterId and PokedexNumber.

Thank you for your help :)

I've been using WildPokemon and MapPokemon for positions. They both give the Latitude and Longitude positions.

For Lured Pokemon (gotten from LureInfo.ActivePokemonId under a Fort/Pokestop), I just use the position of the Pokestop at the moment. Not sure if there is a way to get the actual location.

#243 my comment

Thank you. So i think i need to move the player to get all the pokemons around a position right?
But i often got the problem that WildPokemon and MapPokemon are empty, at positions where some Online-Map-Viewer show pokemons.

Does someone have a code-snippet to get all catchable Pokemons in a radius of 100m (with lat and lng)?

api.Heartbeat(function (err, hb) {
        var mapPokemon = [];
        var nearbyPokemon = [];
        var pokeStops = [];

        if (err) {
            console.log(err);
            return callback({ nearbyPokemon : nearbyPokemon, mapPokemon : mapPokemon, pokeStops : pokeStops });
        };

        // NearbyPokemon
        for (var i = hb.cells.length - 1; i >= 0; i--) {
            if (hb.cells[i].NearbyPokemon[0]) {
                var pokemon = api.pokemonlist[parseInt(hb.cells[i].NearbyPokemon[0].PokedexNumber) - 1];
                nearbyPokemon.push(pokemon);

                console.log('[+] There is a ' + pokemon.name + ' at ' + /*hb.cells[i].NearbyPokemon[0].DistanceMeters.toString() +*/ ' meters');
            }

            // Pokestops
            for (var j = hb.cells[i].Fort.length - 1; j >= 0; j--) {   // You should check if it is near enough to use!!
                var fort = hb.cells[i].Fort[j];

                // 0 = GYM, 1 = PokeStop
                if (fort.FortType == 1 && fort.Enabled) {
                    pokeStops.push(fort);
                }
            }
        }

        if (nearbyPokemon.length == 0) {
            console.log('[+] There is no pokemon near you');
        }

        // Show MapPokemons (catchable) & catch
        for (i = hb.cells.length - 1; i >= 0; i--) {
            for (var j = hb.cells[i].MapPokemon.length - 1; j >= 0; j--) {
                var currentPokemon = hb.cells[i].MapPokemon[j];
                mapPokemon.push(currentPokemon);

                var pokedexInfo = api.pokemonlist[parseInt(currentPokemon.PokedexTypeId) - 1];
                console.log('[+] There is a ' + pokedexInfo.name + ' near!! I can try to catch it! ');
            }
        }
}}