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

google-address-autocomplete

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

google-address-autocomplete - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

.idea/google-address-autocomplete.iml

2

dist/google-address-autocomplete.min.js

@@ -1,1 +0,1 @@

var AddressAutocomplete=function(){"use strict";function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var t=function(){function e(e,t){for(var a=0;a<t.length;a++){var n=t[a];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,a,n){return a&&e(t.prototype,a),n&&e(t,n),t}}();return function(){function a(t,n){if(e(this,a),this.element=document.querySelector(t),!this.element)throw new Error("The element you specified is not a valid element. You should attach an input using a class '.some-class' or an ID '#some-id'.");this.callback=n,this.extractAddress=this.extractAddress.bind(this),this.getUsersLocation=this.getUsersLocation.bind(this),this.handle()}return t(a,[{key:"handle",value:function(){var e=this;document.addEventListener("readystatechange",function(){e.initializeAutocomplete(),e.element.addEventListener("focus",e.getUsersLocation)})}},{key:"initializeAutocomplete",value:function(){this.autocomplete=new google.maps.places.Autocomplete(this.element,{types:["geocode"]}),this.autocomplete.addListener("place_changed",this.extractAddress)}},{key:"extractAddress",value:function(){for(var e={street_number:"short_name",route:"long_name",locality:"long_name",administrative_area_level_1:"short_name",country:"long_name",postal_code:"short_name"},t=this.autocomplete.getPlace(),a=t.address_components,n=t.formatted_address,o={streetNumber:"",streetName:"",cityName:"",stateAbbr:"",zipCode:""},r=0;r<a.length;r++){var s=a[r].types[0];if(e[s])switch(s){case"street_number":o.streetNumber=a[r].long_name;break;case"route":o.streetName=a[r].long_name;break;case"locality":o.cityName=a[r].long_name;break;case"administrative_area_level_1":o.stateAbbr=a[r].short_name,o.state=a[r].long_name;break;case"postal_code":o.zipCode=a[r].long_name;break;case"country":o.countryAbbr=a[r].short_name,o.country=a[r].long_name}}var i=Object.assign({},o,{formattedAddress:n});this.callback(i)}},{key:"getUsersLocation",value:function(){var e=this;navigator.geolocation&&navigator.geolocation.getCurrentPosition(function(t){var a={lat:t.coords.latitude,lng:t.coords.longitude},n=new google.maps.Circle({center:a,radius:t.coords.accuracy});e.autocomplete.setBounds(n.getBounds())})}}]),a}()}();
var AddressAutocomplete=function(){"use strict";function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var t=function(){function e(e,t){for(var a=0;a<t.length;a++){var n=t[a];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,a,n){return a&&e(t.prototype,a),n&&e(t,n),t}}();return function(){function a(t,n){if(e(this,a),this.element=document.querySelector(t),!this.element)throw new Error("The element you specified is not a valid element. You should attach an input using a class '.some-class' or an ID '#some-id'.");this.callback=n,this.extractAddress=this.extractAddress.bind(this),this.getUsersLocation=this.getUsersLocation.bind(this),this.handle()}return t(a,[{key:"handle",value:function(){var e=this;document.addEventListener("readystatechange",function(){e.initializeAutocomplete(),e.element.addEventListener("focus",e.getUsersLocation)})}},{key:"initializeAutocomplete",value:function(){this.autocomplete=new google.maps.places.Autocomplete(this.element,{types:["geocode"]}),this.autocomplete.addListener("place_changed",this.extractAddress)}},{key:"extractAddress",value:function(){for(var e={street_number:"short_name",route:"long_name",locality:"long_name",administrative_area_level_1:"short_name",country:"long_name",postal_code:"short_name"},t=this.autocomplete.getPlace(),a=t.address_components,n=t.formatted_address,o=t.geometry.location,r=o.lat,s=o.lng,i={streetNumber:"",streetName:"",cityName:"",stateAbbr:"",zipCode:"",coordinates:{lat:r(),lng:s()}},c=0;c<a.length;c++){var l=a[c].types[0];if(e[l])switch(l){case"street_number":i.streetNumber=a[c].long_name;break;case"route":i.streetName=a[c].long_name;break;case"locality":i.cityName=a[c].long_name;break;case"administrative_area_level_1":i.stateAbbr=a[c].short_name,i.state=a[c].long_name;break;case"postal_code":i.zipCode=a[c].long_name;break;case"country":i.countryAbbr=a[c].short_name,i.country=a[c].long_name}}var u=Object.assign({},i,{formattedAddress:n});this.callback(u,t)}},{key:"getUsersLocation",value:function(){var e=this;navigator.geolocation&&navigator.geolocation.getCurrentPosition(function(t){var a={lat:t.coords.latitude,lng:t.coords.longitude},n=new google.maps.Circle({center:a,radius:t.coords.accuracy});e.autocomplete.setBounds(n.getBounds())})}}]),a}()}();

@@ -1,2 +0,2 @@

"use strict";function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function e(e,t){for(var a=0;a<t.length;a++){var o=t[a];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,a,o){return a&&e(t.prototype,a),o&&e(t,o),t}}(),AddressAutocomplete=function(){function e(t,a){if(_classCallCheck(this,e),this.element=document.querySelector(t),!this.element)throw new Error("The element you specified is not a valid element. You should attach an input using a class '.some-class' or an ID '#some-id'.");this.callback=a,this.extractAddress=this.extractAddress.bind(this),this.getUsersLocation=this.getUsersLocation.bind(this),this.handle()}return _createClass(e,[{key:"handle",value:function(){var e=this;document.addEventListener("readystatechange",function(){e.initializeAutocomplete(),e.element.addEventListener("focus",e.getUsersLocation)})}},{key:"initializeAutocomplete",value:function(){this.autocomplete=new google.maps.places.Autocomplete(this.element,{types:["geocode"]}),this.autocomplete.addListener("place_changed",this.extractAddress)}},{key:"extractAddress",value:function(){for(var e={street_number:"short_name",route:"long_name",locality:"long_name",administrative_area_level_1:"short_name",country:"long_name",postal_code:"short_name"},t=this.autocomplete.getPlace(),a=t.address_components,o=t.formatted_address,n={streetNumber:"",streetName:"",cityName:"",stateAbbr:"",zipCode:""},s=0;s<a.length;s++){var r=a[s].types[0];if(e[r])switch(r){case"street_number":n.streetNumber=a[s].long_name;break;case"route":n.streetName=a[s].long_name;break;case"locality":n.cityName=a[s].long_name;break;case"administrative_area_level_1":n.stateAbbr=a[s].short_name,n.state=a[s].long_name;break;case"postal_code":n.zipCode=a[s].long_name;break;case"country":n.countryAbbr=a[s].short_name,n.country=a[s].long_name}}var c=Object.assign({},n,{formattedAddress:o});this.callback(c)}},{key:"getUsersLocation",value:function(){var e=this;navigator.geolocation&&navigator.geolocation.getCurrentPosition(function(t){var a={lat:t.coords.latitude,lng:t.coords.longitude},o=new google.maps.Circle({center:a,radius:t.coords.accuracy});e.autocomplete.setBounds(o.getBounds())})}}]),e}();module.exports=AddressAutocomplete;
"use strict";function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function e(e,t){for(var a=0;a<t.length;a++){var o=t[a];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,a,o){return a&&e(t.prototype,a),o&&e(t,o),t}}(),AddressAutocomplete=function(){function e(t,a){if(_classCallCheck(this,e),this.element=document.querySelector(t),!this.element)throw new Error("The element you specified is not a valid element. You should attach an input using a class '.some-class' or an ID '#some-id'.");this.callback=a,this.extractAddress=this.extractAddress.bind(this),this.getUsersLocation=this.getUsersLocation.bind(this),this.handle()}return _createClass(e,[{key:"handle",value:function(){var e=this;document.addEventListener("readystatechange",function(){e.initializeAutocomplete(),e.element.addEventListener("focus",e.getUsersLocation)})}},{key:"initializeAutocomplete",value:function(){this.autocomplete=new google.maps.places.Autocomplete(this.element,{types:["geocode"]}),this.autocomplete.addListener("place_changed",this.extractAddress)}},{key:"extractAddress",value:function(){for(var e={street_number:"short_name",route:"long_name",locality:"long_name",administrative_area_level_1:"short_name",country:"long_name",postal_code:"short_name"},t=this.autocomplete.getPlace(),a=t.address_components,o=t.formatted_address,n=t.geometry.location,s=n.lat,r=n.lng,c={streetNumber:"",streetName:"",cityName:"",stateAbbr:"",zipCode:"",coordinates:{lat:s(),lng:r()}},i=0;i<a.length;i++){var l=a[i].types[0];if(e[l])switch(l){case"street_number":c.streetNumber=a[i].long_name;break;case"route":c.streetName=a[i].long_name;break;case"locality":c.cityName=a[i].long_name;break;case"administrative_area_level_1":c.stateAbbr=a[i].short_name,c.state=a[i].long_name;break;case"postal_code":c.zipCode=a[i].long_name;break;case"country":c.countryAbbr=a[i].short_name,c.country=a[i].long_name}}var u=Object.assign({},c,{formattedAddress:o});this.callback(u,t)}},{key:"getUsersLocation",value:function(){var e=this;navigator.geolocation&&navigator.geolocation.getCurrentPosition(function(t){var a={lat:t.coords.latitude,lng:t.coords.longitude},o=new google.maps.Circle({center:a,radius:t.coords.accuracy});e.autocomplete.setBounds(o.getBounds())})}}]),e}();module.exports=AddressAutocomplete;
//# sourceMappingURL=index.js.map
{
"name": "google-address-autocomplete",
"version": "1.2.0",
"version": "1.3.0",
"description": "This is a package that gives an input address autocomplete by using Google's lookup.",

@@ -30,5 +30,5 @@ "keywords": [

"scripts": {
"build": "./node_modules/rollup/bin/rollup --config rollup.config.js",
"start": "./node_modules/rollup/bin/rollup --config rollup.config.js --watch",
"start:contrib": "./node_modules/rollup/bin/rollup --config contrib/rollup.config.js --watch",
"build": "rollup --config rollup.config.js",
"start": "rollup --config rollup.config.js --watch",
"start:contrib": "rollup --config contrib/rollup.config.js --watch",
"test": "eslint ./src",

@@ -35,0 +35,0 @@ "lint": "npm test",

@@ -38,5 +38,19 @@ # Google Address Autocomplete

zipCode: "35226",
coordinates: {
lat: -123.45678
lng: 98.76543
}
};
});
```
> **NOTE:** There is an optional second parameter that will dump out the raw response from Google. So, it
> look like this:
```JavaScript
new AddressAutocomplete('#my-input-id-or-class-name', results, rawResults);
```
You can use a callback for both of them to get the results of each.
*Big thanks to [@Braunson](https://github.com/Braunson) for his help with this!*
And include your final bundle in your HTML like this.

@@ -113,1 +127,4 @@ ```HTML

If you find an issue, submit it and let's fix it!
# Contributors
[Check out these awesome people!](https://github.com/dericcain/google-address-autocomplete/graphs/contributors)

@@ -5,2 +5,3 @@ /**

* @author Deric Cain <deric.cain@gmail.com>
* @contributor Braunson Yager <braunson@gmail.com>
*/

@@ -74,6 +75,13 @@ export default class AddressAutocomplete {

const resultRaw = this.autocomplete.getPlace();
const {
address_components,
formatted_address,
} = this.autocomplete.getPlace();
geometry: {
location: {
lat,
lng
}
}
} = resultRaw;
const addressObject = {

@@ -85,2 +93,3 @@ streetNumber: '',

zipCode: '',
coordinates: { lat: lat(), lng: lng() },
};

@@ -119,8 +128,8 @@

const result = Object.assign({}, addressObject, {
formattedAddress: formatted_address,
const resultFormatted = Object.assign({}, addressObject, {
formattedAddress: formatted_address
});
// This is where we check for the callback and then call it, passing our resutls
this.callback(result);
this.callback(resultFormatted, resultRaw);
}

@@ -127,0 +136,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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