Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
A utility for getting geo-location information, geocoding, address look-ups, distance & durations, timezone information and more...
© 2016, Onur Yıldırım (@onury) MIT License. Please see the Disclaimer and License.
Geolocator.js is a utility for getting geo-location information, geocoding, address look-ups, distance & durations, timezone information and more...
If you're migrating from v1.x to v2, you should consider the following changes:
err
as the first argument. If it's a success, err
will be null
..location
property is dropped. You can always access the result, via the second argument of each async method's callback.geolcoator.setGeoIPSource()
method to set a different Geo-IP source.Link or download via CDNJS.
Download full source code from GitHub releases.
Install via Bower:
bower install geolocator
Install via NPM:
npm install geolocator
If somehow you need the legacy version v1.2.9 and don't need the better. Here it is.
Example below, tries to get user's geo-location via HTML5 Geolocation and if user rejects, it will fallback to IP based geo-location.
Inside the <head>
of your HTML:
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/geolocator/2.0.0/geolocator.min.js"></script>
<script type="text/javascript">
geolocator.config({
language: "en",
google: {
version: "3",
key: "YOUR-GOOGLE-API-KEY"
}
});
window.onload = function () {
var options = {
enableHighAccuracy: true,
timeout: 6000,
maximumAge: 0,
desiredAccuracy: 30,
fallbackToIP: true, // fallback to IP if Geolocation fails or rejected
addressLookup: true,
timezone: true,
map: "map-canvas"
};
geolocator.locate(options, function (err, location) {
if (err) return console.log(err);
console.log(location);
});
};
</script>
If you've enabled map
option; include the following, inside the <body>
of your HTML:
<div id="map-canvas" style="width:600px;height:400px"></div>
Read API documentation for lots of other features and examples.
doctype
is HTML5 (e.g. <!DOCTYPE html>
).geolocator.locate()
and geolocator.watch()
) from a secure origin (i.e. an HTTPS page). In Chrome 50, Geolocation API is removed from unsecured origins. Other browsers are expected to follow.Geolocator v2 is written in ES2015 (ES6), compiled with Babel, bundled with Webpack and documented with Docma.
MIT. See the Disclaimer and License.
FAQs
A utility for getting geo-location information via HTML5 and IP look-ups, geocoding, address look-ups, distance and durations, timezone information and more...
We found that geolocator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.