1666962720
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
Author: JCSama
Source Code: https://github.com/JCSama/CodeIgniter-geolocation
License: MIT license
1662811500
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.
Native NodeJS implementation of MaxMind's GeoIP API -- works in node 0.6.3 and above, ask me about other versions
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.
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 }
$ npm install geoip-lite
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.
Node.js + ipapi (IP address location API)
npm install ipapi.co
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
Maxmind GeoIP2 Web Services for Node.js
You can provide the configuration in the require function or inline at lookup time. The lookup always returns a Promise.
const geo = require ('geoip2ws') ({
userId: '12345',
licenseKey: 'abc678',
});
geo ({
service: 'city',
ip: '1.2.3.4',
})
.then (console.log)
.catch (console.error)
;
const geo = require ('geoip2ws')();
geo ({
userId: '12345',
licenseKey: 'abc678',
service: 'city',
ip: '1.2.3.4',
})
.then (console.log)
.catch (console.error)
;
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
A Node.js module for retrieving a request's IP address on the server.
Yarn
yarn add request-ip
npm
npm install request-ip --save
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
const requestIp = require('request-ip');
app.use(requestIp.mw())
app.use(function(req, res) {
const ip = req.clientIp;
res.end(ip);
});
Find geolocation data from IP addresses (e.g. city, country, timezone) using the IPLocate.io API
npm install node-iplocate
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"
}
A light-weight IP address based connection filtering system
Recommended installation is with npm. To add express-ipfilter to your project, do:
npm install express-ipfilter
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
Google Maps Geolocation API for Node.js (unofficial)
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);
})
;
npm i google-geolocation
Thank you for following this article.
API-Review of an IP Geolocation API
1657564680
Stream in nearby places using the browser's geolocation, a convenient client-side counterpart to level-places.
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'
Create a readable stream that emits nearby places.
Possible options are:
timeout (Number)
: Give up finding the current position after x milisecondsignoreErrors (Boolean)
: If true, when a geolocation error happens, an empty position will be used.Emits position
when geo-position
finds it.
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:
1652448720
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
1651299360
Libraries for geocoding addresses and working with latitudes and longitudes.
Author: ziadoz
Source Code: https://github.com/ziadoz/awesome-php
License: WTFPL License
1650833220
Libraries for geocoding addresses and working with latitudes and longitudes.
Author: vinta
Source Code: https://github.com/vinta/awesome-python
License: View license
1646164767
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
1626955020
Geolocation - Covid-19 Tracker App using Flutter.
Github - https://github.com/theindianinnovation/covid-19
#flutter #geolocation #tracker app #covid-19
1626103513
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
1622760720
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
1622744580
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
1609260000
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.
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.
https://techtolia.medium.com/geolocation-by-ip-address-in-asp-net-3159e2e83575
#geolocation #aspnet #dotnet #csharp #iplocation
1608812850
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
1603813080
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:
#javascript #mapbox #web-development #geolocation #web-components
1603089184
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.
We will start by installing our SDK:
npm install cloudmersive-validate-api-client --save
#node-js-tutorial #api #nodejs #ux #geolocation