Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@mapquest/geocoding

Package Overview
Dependencies
Maintainers
4
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mapquest/geocoding - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

client.js

26

index.js

@@ -42,2 +42,13 @@ 'use strict';

function covertToGeoJson(location){
return {
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [location.latLng.lng, location.latLng.lat]
},
"properties": location
}
}
class Geocoding {

@@ -57,2 +68,17 @@ constructor(options){

forward(address){
return request
.get(this.options.url + '/address')
.query({key: this.options.key,
location: address
})
.then(response => response.body.results[0].locations[0])
.then(covertToGeoJson)
.catch(err =>{
if(err.response && err.response.text) return Promise.reject(err.response.text);
return Promise.reject(err);
})
}
reverse(lat, lng){

@@ -59,0 +85,0 @@ return request

2

package.json
{
"name": "@mapquest/geocoding",
"version": "0.0.3",
"version": "0.0.4",
"description": "MapQuest Geocoding",

@@ -5,0 +5,0 @@ "main": "index.js",

# MQ Geocoding
A JavaScript interface to the MapQuest geocoding service. You must obtain a key before using this service. This module
can be used in the browser and server side.
A JavaScript interface to the [MapQuest Geocoding API](https://developer.mapquest.com/documentation/geocoding-api/).
You must obtain a key before using this service. This module can be used in the browser and server side.
Examples:
```javascript
//setup the module
const Geocoding = require('@mapquest/geocoding');
const client = new Geocoding({key: 'xxxxxxx'})
client.reverse(lat, lng)
//forward geocode
client.forward('1555 Blake St. Denver, CO 80204')
.then(result => {
console.log(result); // returns a GeoJson point of the first match
})
//reverse geocode
client.reverse(39.75, -104.99) //lat, lng
.then(result => {
console.log(result.addressString); //single line address, ie: "1555 Blake St., Denver, CO 80204"

@@ -13,0 +23,0 @@ console.log(result.location); //geocoding service response

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc