dericcain / google-address-autocomplete Goto Github PK
View Code? Open in Web Editor NEWA library that attaches Google address autocomplete to a text input.
A library that attaches Google address autocomplete to a text input.
If you look at #1 you will see that this library now has the ability to handle multiple instances of the autocomplete. Essentially, you can do this:
new AddressAutocomplete('.shipping-address', result => console.log(result));
new AddressAutocomplete('.billing-address', result => console.log(result));
And it will work just fine. The docs need to be updated to show that this can be accomplished.
I'm having an issue with non US addresses. Just testing it out, I used 10 Downing Street, but no city or localities are returned.
Here are the results:
{
cityName: "",
coordinates: Object { lat: 51.5033635, lng: -0.1276248 },
country: "United Kingdom",
countryAbbr: "GB",
formattedAddress: "10 Downing St, Westminster, London SW1A 2AB, UK",
state: "England",
stateAbbr: "England",
streetName: "Downing Street",
streetNumber: "10",
zipCode: "SW1A 2AB"
}
Both Westminster and London are in the formattedAddress
, but missing from cityName
.
Are there options to enable the localities that I'm missing?
Instead of requiring a user to insert their own Google script tags, we can handle this and even insert their key for them.
@dericgw
I'm looking to initialize a second input that's ajax loaded on a page.
First the page loads with one input which get's initiated no problem.
Once the page is finished loading, it will make an Ajax call to include another input that should be initiated and says it is but it doesn't work as expected, nothing happens.
Ideas?
If you look at the contributing link at the bottom of the readme, the link is broken because it has .ms
instead of .md
as an extension. You should just be able to change the one letter from s
to d
to fix it.
Hello,
Thank you for your tool.
Is it possible to make possible to add options to Autocomplete? For example I would like to restrict the area to a country. The code is the following:
this.autocomplete = new google.maps.places.Autocomplete(this.element, {
types: ["geocode"],
componentRestrictions: {country: "fr"} // This option to restrict to France
}), this.autocomplete.addListener("place_changed", this.extractAddress)
Can you add the possibility to add options, for example like this:
var options= {
componentRestrictions: {country: "fr"}
}
new AddressAutocomplete("#address-search", options, results => {...})
It will be necessary to merge with default option types: ["geocode"]
Thanks for your help!
It would be nice to access other data in the response such as
Hello,
Is there any option to add an event listener to suggestions? I would like to submit the parent form of the input element when an item is on the list of addresses is clicked.
Just a note, not an issue if your using HTTPS but the warning is there for non-https users.
[Deprecation] getCurrentPosition() and watchPosition() no longer work on insecure origins. To use this feature, you should consider switching your application to a secure origin, such as HTTPS. See https://goo.gl/rStTGz for more details.
For instance, we should be able to do this:
new AddressAutocomplete('.shipping-address', result => console.log(result));
new AddressAutocomplete('.billing-address', result => console.log(result));
As it is right now, when you instantiate the second input, it will overwrite the first one.
After giving a look in the source code, I see that there is being used the readyStateChange
(https://github.com/dericgw/google-address-autocomplete/blob/master/src/index.js#L65) event. But this one only is fired within Internet Explorer and Microsoft Edge.
So on Chrome and Firefox this library would not be working...
I suggest a change to check if the document finished to load. Instead of this one.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.