Leonard  Paucek

Leonard Paucek

1666962720

CodeIgniter Geolocation: Library Allows You to Locate an IP Address

CodeIgniter Geolocation Library

CodeIgniter Geolocation library allows you to locate an IP Address using "ipinfodb" API.

Installation

CodeIgniter Versoin >= 2.x.x

Copy the file config/geolocation.php to the application/config folder.

Copy the file libraries/geolocation.php to the application/libraries folder.

Usage

You need to subscribe to http://ipinfodb.com/register.php to get your API KEY and then,

Open application/config/geolocation.php and put it there :

$config['api_key'] = 'YOUR_API_KEY';

After that, you can call the library within your controller for instance like following :

$this->load->library('Geolocation');
$this->load->config('geolocation', true);

$config = $this->config->config['geolocation'];

$this->geolocation->initialize($config);
$this->geolocation->set_ip_address($ip); // IP to locate
// $this->geolocation->set_format('json');
// OR you can change the format within `config/geolocation.php` config file
$country = $this->geolocation->get_country();
var_dump($country);

// For more precision
$city = $this->geolocation->get_city();
if($city === FALSE)
    var_dump($this->geolocation->get_error());
else
    var_dump($city);

Additional parameters

You can change the result format within the config file, or leave it empty to return a PHP Array

Open application/config/geolocation.php :

$config['format'] = 'json'; // available format : xml|raw|json  or empty for php array

IpInfoDb API :

For more information about the API please visit : http://ipinfodb.com


Download Details:

Author: JCSama
Source Code: https://github.com/JCSama/CodeIgniter-geolocation

License: MIT license

#geolocation 

CodeIgniter Geolocation: Library Allows You to Locate an IP Address
Sheldon  Grant

Sheldon Grant

1662811500

7 Favorite Node.js IP Geolocation API Libraries

In today's post we will learn about 7 Favorite Node.js IP Geolocation API Libraries. 

Geolocation has to be one of the most underrated yet rewarding innovations for the modern generation. Words cannot describe the impact it has had on our day-to-day personal and professional lives. From tracking lost devices to finding restaurants nearby to dine at, Geolocation has become an integral part of our daily lives.

Geolocation can be simply defined as the process by which the geographic location of a radar source, mobile network, or internet-connected devices can be identified. An IP Geolocation API is a technology that can identify the real-world location of a device connected to the internet.

1 - Node-geoip

Native NodeJS implementation of MaxMind's GeoIP API -- works in node 0.6.3 and above, ask me about other versions

why geoip-lite

geoip-lite is a fully JavaScript implementation of the MaxMind geoip API. It is not as fully featured as bindings that use libgeoip. By reducing scope, this package is about 40% faster at doing lookups. On average, an IP to Location lookup should take 20 microseconds on a Macbook Pro. IPv4 addresses take about 6 microseconds, while IPv6 addresses take about 30 microseconds.

synopsis

var geoip = require('geoip-lite');

var ip = "207.97.227.239";
var geo = geoip.lookup(ip);

console.log(geo);
{ range: [ 3479298048, 3479300095 ],
  country: 'US',
  region: 'TX',
  eu: '0',
  timezone: 'America/Chicago',
  city: 'San Antonio',
  ll: [ 29.4969, -98.4032 ],
  metro: 641,
  area: 1000 }

installation

1. get the library

$ npm install geoip-lite

2. update the datafiles (optional)

Run cd node_modules/geoip-lite && npm run-script updatedb license_key=YOUR_LICENSE_KEY to update the data files. (Replace YOUR_LICENSE_KEY with your license key obtained from maxmind.com)

You can create maxmind account here

NOTE that this requires a lot of RAM. It is known to fail on on a Digital Ocean or AWS micro instance. There are no plans to change this. geoip-lite stores all data in RAM in order to be fast.

View on Github

2 - ipapi-nodejs

Node.js + ipapi (IP address location API)

Installation

npm install ipapi.co

Usage

From Node.js REPL

var ipapi = require('ipapi.co');

var callback = function(res){
    console.log(res);
};

ipapi.location(callback)       // Complete location for your IP address
> { 
    ip: '50.1.2.3',
    city: 'Wilton',
    region: 'California',
    country: 'US',
    postal: 95693,
    latitude: 38.3926,
    longitude: -121.2429,
    timezone: 'America/Los_Angeles' 
  }


ipapi.location(callback, '', '', 'ip')         // Your external IP address
50.1.2.3

ipapi.location(callback, '', '', 'city')       // Your city
Wilton

ipapi.location(callback, '', '', 'country')    // Your country
US

ipapi.location(callback, '8.8.8.8')            // Complete location for IP address 8.8.8.8
> { 
    ip: '8.8.8.8',
    city: 'Mountain View',
    region: 'California',
    country: 'US',
    postal: '94035',
    latitude: 37.386,
    longitude: -122.0838,
    timezone: 'America/Los_Angeles' 
}

ipapi.location(callback, '8.8.8.8', '', 'city')       // City for IP address 8.8.8.8
Mountain View

ipapi.location(callback, '8.8.8.8', '', 'country')       // Country for IP address 8.8.8.8
US

View on Github

3 - Nodejs-geoip2ws

Maxmind GeoIP2 Web Services for Node.js

Usage

You can provide the configuration in the require function or inline at lookup time. The lookup always returns a Promise.

Normal configuration

const geo = require ('geoip2ws') ({
  userId: '12345',
  licenseKey: 'abc678',
});

geo ({
  service: 'city',
  ip: '1.2.3.4',
})
  .then (console.log)
  .catch (console.error)
;

Inline configuration

const geo = require ('geoip2ws')();

geo ({
  userId: '12345',
  licenseKey: 'abc678',
  service: 'city',
  ip: '1.2.3.4',
})
  .then (console.log)
  .catch (console.error)
;

Installation

You need a Maxmind account ID and license key with enough credits for one of their GeoIP web services. You can find both here.

npm i geoip2ws

View on Github

4 - Request-ip

A Node.js module for retrieving a request's IP address on the server.

Installation

Yarn

yarn add request-ip

npm

npm install request-ip --save

Getting Started

const requestIp = require('request-ip');

// inside middleware handler
const ipMiddleware = function(req, res, next) {
    const clientIp = requestIp.getClientIp(req); 
    next();
};

// on localhost you'll see 127.0.0.1 if you're using IPv4 
// or ::1, ::ffff:127.0.0.1 if you're using IPv6

As Connect Middleware

const requestIp = require('request-ip');
app.use(requestIp.mw())

app.use(function(req, res) {
    const ip = req.clientIp;
    res.end(ip);
});

View on Github

5 - Node-iplocate

Find geolocation data from IP addresses (e.g. city, country, timezone) using the IPLocate.io API

Installation

npm install node-iplocate

Usage Example

const iplocate = require("node-iplocate");

iplocate("8.8.8.8").then(function(results) {
  console.log("IP Address: " + results.ip);
  console.log("Country: " + results.country + " (" + results.country_code + ")");
  console.log("Continent: " + results.continent);
  console.log("Organisation: " + results.org + " (" + results.asn + ")");

  console.log(JSON.stringify(results, null, 2));
});

// Or with callbacks
iplocate("8.8.8.8", null, function(err, results) {
  // ...
  console.log(JSON.stringify(results, null, 2));
});

// Provide an API key from IPLocate.io
iplocate("8.8.8.8", { api_key: "abcdef" }).then(function(results) {
  // ...
});

IP Address: 8.8.8.8
Country: United States (US)
Continent: North America
Organisation: Google LLC (AS15169)

{
  "ip": "8.8.8.8",
  "country": "United States",
  "country_code": "US",
  "city": null,
  "continent": "North America",
  "latitude": 37.751,
  "longitude": -97.822,
  "time_zone": null,
  "postal_code": null,
  "org": "Google LLC",
  "asn": "AS15169"
}

View on Github

6 - Express-ipfilter

A light-weight IP address based connection filtering system

Installation

Recommended installation is with npm. To add express-ipfilter to your project, do:

npm install express-ipfilter

Usage with Express

Denying certain IP addresses, while allowing all other IPs:

// Init dependencies
const express = require('express')
const ipfilter = require('express-ipfilter').IpFilter

// Deny the following IPs
const ips = ['127.0.0.1']

// Create the server
app.use(ipfilter(ips))
app.listen(3000)

Allowing certain IP addresses, while denying all other IPs:

// Init dependencies
// Init dependencies
const express = require('express')
const ipfilter = require('express-ipfilter').IpFilter

// Allow the following IPs
const ips = ['127.0.0.1']

// Create the server
app.use(ipfilter(ips, { mode: 'allow' }))

module.exports = app

View on Github

7 - Nodejs-geolocation

Google Maps Geolocation API for Node.js (unofficial)

Example

const geo = require ('google-geolocation');

function out (obj) {
  console.dir (obj, {
    depth: null,
    colors: true,
  });
}

// Get data
geo ({
  key: 'abc123',
  wifiAccessPoints: [{
    macAddress: '01:23:45:67:89:AB',
    signalStrength: -65,
    signalToNoiseRatio: 40,
  }],
})
  .then (out)
  .catch (err => {
    out (err);
    process.exit (1);
  })
;

Installation

npm i google-geolocation

View on Github

Thank you for following this article. 

Related videos:

API-Review of an IP Geolocation API

#node #geolocation #ip 

7 Favorite Node.js IP Geolocation API Libraries

Stream in Nearby Places using The Browser's Geolocation & Level-places

level-nearby-stream

Stream in nearby places using the browser's geolocation, a convenient client-side counterpart to level-places.

Usage

Add some cities, then query for ones nearby.

var Places = require('level-places');
var createNearbyStream = require('level-nearby-stream');

// get db from multilevel or level-js
var places = Places(db);

places.add('NYC', 40.7142, -74.0064);
places.add('KFB', 47.8800, 10.6225);

createNearbyStream(places).on('data', console.log);
// => 'KFB'
//    'NYC'

API

createNearbyStream(places, options)

Create a readable stream that emits nearby places.

Possible options are:

  • timeout (Number): Give up finding the current position after x miliseconds
  • ignoreErrors (Boolean): If true, when a geolocation error happens, an empty position will be used.
  • plus all the options from places#createReadStream
  • plus all the options from trie#createSearchStream

stream#on('position', fn(position))

Emits position when geo-position finds it.

Installation

With npm do

$ npm install level-nearby-stream

Then bundle for the client using browserify.

Author: juliangruber
Source Code: https://github.com/juliangruber/level-nearby-stream 
License: 

#javascript #node #stream #geolocation 

Stream in Nearby Places using The Browser's Geolocation & Level-places
Emmet  Blick

Emmet Blick

1652448720

How to Retrieve Location using Geolocation API

This video covers the geolocation API, which allows us to detect a user's location. 

Timestamps: 
0:00 Introduction
0:30 Geolocation background
1:24 Retrieving a users location

#api #geolocation #javascript 

How to Retrieve Location using Geolocation API
Veronica  Roob

Veronica Roob

1651299360

Awesome PHP: Libraries for Geocoding Addresses

Geolocation

Libraries for geocoding addresses and working with latitudes and longitudes.

  • Country List - A list of all countries with names and ISO 3166-1 codes.
  • GeoCoder - A geocoding library.
  • GeoJSON - A GeoJSON implementation.
  • GeoTools - A library of geo-related tools.
  • PHPGeo - A simple geo library.

Author: ziadoz
Source Code: https://github.com/ziadoz/awesome-php
License: WTFPL License

#php #geolocation 

Awesome PHP: Libraries for Geocoding Addresses

Awesome Python: Libraries for Working with Latitudes and Longitudes

Geolocation

Libraries for geocoding addresses and working with latitudes and longitudes.

  • django-countries - A Django app that provides a country field for models and forms.
  • GeoDjango - A world-class geographic web framework.
  • GeoIP - Python API for MaxMind GeoIP Legacy Database.
  • geojson - Python bindings and utilities for GeoJSON.
  • geopy - Python Geocoding Toolbox.

Author: vinta
Source Code: https://github.com/vinta/awesome-python
License: View license

#python #geolocation 

Awesome Python: Libraries for Working with Latitudes and Longitudes

✨ Geo-Locate IPs With Python ✨

Geolocating an IP address is a convenient way to identify a user's real-world location.

We shall majorly be using requests library and JSON for today.

#python #codenewbies #apis #geolocation

Read More 👇

https://blog.octachart.com/geo-locate-ips-with-python

✨ Geo-Locate IPs With Python ✨
Kaia  Schmitt

Kaia Schmitt

1626955020

How to Use Geolocation in Flutter | Covid-19 Tracker App | Part - 2 | Flutter | CodeStudio

Geolocation - Covid-19 Tracker App using Flutter.
Github - https://github.com/theindianinnovation/covid-19

#flutter #geolocation #tracker app #covid-19

How to Use Geolocation in Flutter | Covid-19 Tracker App | Part - 2 | Flutter | CodeStudio
Vincent Lab

Vincent Lab

1626103513

Get started with the What3Words API in Node.js

In this video, I’ll be showing you how to get started with the What3Words API in Node.js

✅ Project files
https://github.com/VLabStudio/Tutorials/tree/master/Get started with the What3Words API in Node.js

#node js #what3words #backend #geolocation #latitude and longitude #w3w

Get started with the What3Words API in Node.js

AWS Introduces Location Service in Preview

In one of the latest announcements of re:Invent 2020, AWS introduced the preview of Amazon Location, a new mapping service for developers to add location-based features like geofencing and built-in tracking to web-based and mobile applications.

The new product offers currently four different types of resources - maps, place indexes, trackers and geofence collections - and an API for routing is expected to be added during the preview. While the place indexes API allow searching for addresses, businesses, and points of interest using free-form text, trackers can be linked to geofence collections to implement monitoring of devices as they move in and out of geofences. The service supports maps and map styles provided by Esri and by HERE Technologies, two of the largest location data providers, and it is possible to use existing map libraries such as Mapbox GL and Tangram. As for the documentation, the API is consistent across LBS data providers, making it possible to switch across different providers for different use cases or geographies.

The service will help in use cases such as displaying maps, tracking the movement of packages and devices, geomarketing, geocoding (turn an address into a location) and delivery management. Even if not all geolocation functionalities are yet available, the cloud provider is going to cover an area where it was not offering a managed solution, competing now in the location data market with Google Maps Platform and Azure Maps.

#geolocation #maps #aws #cloud

AWS Introduces Location Service in Preview

AWS Introduces Location Service in Preview

In one of the latest announcements of re:Invent 2020, AWS introduced the preview of Amazon Location, a new mapping service for developers to add location-based features like geofencing and built-in tracking to web-based and mobile applications.

The new product offers currently four different types of resources - maps, place indexes, trackers and geofence collections - and an API for routing is expected to be added during the preview. While the place indexes API allow searching for addresses, businesses, and points of interest using free-form text, trackers can be linked to geofence collections to implement monitoring of devices as they move in and out of geofences. The service supports maps and map styles provided by Esri and by HERE Technologies, two of the largest location data providers, and it is possible to use existing map libraries such as Mapbox GL and Tangram. As for the documentation, the API is consistent across LBS data providers, making it possible to switch across different providers for different use cases or geographies.

The service will help in use cases such as displaying maps, tracking the movement of packages and devices, geomarketing, geocoding (turn an address into a location) and delivery management. Even if not all geolocation functionalities are yet available, the cloud provider is going to cover an area where it was not offering a managed solution, competing now in the location data market with Google Maps Platform and Azure Maps.

#geolocation #maps #aws #cloud

AWS Introduces Location Service in Preview
Techtolia ✓

Techtolia ✓

1609260000

Geolocation by IP Address in ASP.NET

Demo: https://techtolia.com/IpLocation/

What is Geolocation by IP Address in ASP.NET?

With integrating the module to your ASP.NET web forms, get location details of users by their IPv4, or check location details for any IPv4. IP location is not exact location, it generally represents city location.

The module comes with two types database connection options and database files, and ready to use. First: Loading database from the mdf database file with Ado.Net connection model. Second: Loading database from csv file (a bit slower).

Also, you can import database from csv to your database, use your database connection and load data.

Database includes 2.5+ million IP-Geolocation records. Records include ip from, ip to, country code, country, region, city, latitude, longitude, postal code, time zome.

Extra: The module uses Google Maps APIs to show the location on map from latitude-longitude location details.
Full source code and the database files are included.

What is IP Geolocation?

IP Geolocation is mapping of an IP address to the real-world geographic location of a device. Geolocation involves in mapping IPv4 address to country code, country, region, city, latitude, longitude, postal code, time zome.

Accuracy of geolocation database is not 100% because there is not any official source of IP to Geolocation information.

Alt Text

Alt Text

https://techtolia.medium.com/geolocation-by-ip-address-in-asp-net-3159e2e83575

#geolocation #aspnet #dotnet #csharp #iplocation

Geolocation by IP Address in ASP.NET
Jonah Lawrence

Jonah Lawrence

1608812850

Getting the user's location with JavaScript (Geolocation API tutorial)


Using the Geolocation API to get the coordinates and address of a user with JavaScript

Tutorial: https://www.youtube.com/watch?v=JdJ2VBbYYTQ

In this tutorial, I will show you how to use the navigator.geolocation API and the OpenCage API in JavaScript to get the user’s coordinates, address, and city.

We will then use this to improve the weather app from last video
▶ Build a Weather App - https://youtu.be/WZNG8UomjSI

We will make the weather app display the weather for the user’s current location as soon as they open the page.

Follow me on Twitter for JavaScript tips and quizzes!
https://twitter.com/DenverCoder1

👨‍💻 My code
https://github.com/DenverCoder1/weather-app-tutorial

What topics should I cover next?

Let me know in the comments what you want to see next in my tutorials!

🖥 More Web Development tutorials
https://www.youtube.com/playlist?list=PL9YUC9AZJGFFAErr_ZdK2FV7sklMm2K0J

💻 More tutorials
https://www.youtube.com/playlist?list=PL9YUC9AZJGFHTUP3vzq4UfQ76ScBnOi-9

🙋‍♂️ Find me on other channels
Reddit 👽 https://www.reddit.com/r/DevProTips/
Twitter ✍ https://twitter.com/DenverCoder1
Github 👨‍💻 https://github.com/DenverCoder1
Sponsor 💞 https://github.com/sponsors/DenverCoder1
One-time donation ☕ https://ko-fi.com/jlawrence

💖 SPONSORS 💖
Get your username or a link to your channel here by sponsoring on Github
https://github.com/sponsors/DenverCoder1

🎁 GET FREE STUFF WHILE SUPPORTING MY TUTORIALS
https://bit.ly/jlawrencepromos

#webdev #geolocation #javascript #api #tutorial

Getting the user's location with JavaScript (Geolocation API tutorial)
Autumn  Blick

Autumn Blick

1603813080

How to build a reusable geolocation && reverse-geocoding Web Component

This little article will show you how to build a simple web page that will automatically locate your position, paint it on a map, and show you the text address corresponding to the map’s coordinates.

First of all, Let’s define some terms:

Geolocation identifies or estimates an object’s real-world geographic location, such as a building or mobile phone.

**Geocoding **is the process of taking input text, such as an address or the name of a place, and returning a latitude/longitude location on the Earth’s surface for that place.

Reverse-Geocoding is the process of converting addresses (like “ 10 Downing Stree**”**) into his latitude and longitude geographic coordinates, which you can use to place markers on a map or position the map.

Having clarified the previous terms, we will need the following to build our location page:

  • MapBox for maps. It would help if you had a free API token to use his API.
  • Basic JavaScript knowledge.
  • Jquery and JqueryUI to display a dialog with the selected address. You can use an “alert” if you do not want to use Jquery.
  • We are going to use a JS online editor for trying it (optional). In the references at the end of the article, I leave a link to the web app created in this tutorial.
  • We are going to use LitElement to build a Web Component. LitElement is a simple implementation that follows the Web Components standards specification.

#javascript #mapbox #web-development #geolocation #web-components

How to build a reusable geolocation && reverse-geocoding Web Component
Ben Taylor

Ben Taylor

1603089184

How to Geolocate an IP Address to a Street Address in Node.js

We previously posted an article on performing basic geolocation of an IP address using one of our APIs. Now, we have and API that will go even further. Ideal for UX and security applications, this new function will allow you to geolocate an IP Address down to its actual street address. By inputting an IP Address string (i.e. 55.55.55.55), you can return the country and country code, street address, city name, region name, and Zip code. This will allow you to better understand your client base and track any incoming threats to your sites.

Image for post

We will start by installing our SDK:

npm install cloudmersive-validate-api-client --save

#node-js-tutorial #api #nodejs #ux #geolocation

How to Geolocate an IP Address to a Street Address in Node.js