Comments (12)
I dont think you can with google geocoder
If you find a solution please share
from jquery-addresspicker.
you have to filter the results in _geocode function
you iterate in result object in order to find type=="country" & shortname==your country code and you only take the one that met this condition
here is my modified function for france adresses, it is a bit dirty but it works
// Autocomplete source method: fill its suggests with google geocoder results
_geocode: function(request, response) {
var address = request.term, self = this;
this.geocoder.geocode({
'address': address + this.options.appendAddressString,
'region': this.options.regionBias
}, function(results, status) {
var fr_results= [];
if (status == google.maps.GeocoderStatus.OK) {
for (var i = 0; i < results.length; i++) {
results[i].label = results[i].formatted_address;
for (var j = 0; j<results[i].address_components.length; j++)
{
//console.log(results[i]);
if ((results[i].address_components[j].types[0] =="country") && (results[i].address_components[j].short_name =="FR"))
{
//console.log(results[i].address_components[j].short_name);
results[i].label = results[i].formatted_address;
//fr_results[i] = results[i];
fr_results.push(results[i]);
}
}
};
}
//console.log(results);
//console.log(fr_results);
response(fr_results);
})
},
from jquery-addresspicker.
This is great! But how do I get this to work for UK area? I changed the short_name to UK and GB and can see nothing else in the code that would require to be changed. I've tried other short country names but nothing works except France... am I missing something obvious?
from jquery-addresspicker.
I changed the entry to GB over a week ago which produced no results but it seems to be working now. Seems it didn't work instantly but can't understand why :/
from jquery-addresspicker.
I made a fork that supports this feature : https://github.com/xurei/jquery-addresspicker
Usage :
$( 'input[name="address"]' ).addresspicker({
...,
componentsFilter: 'country:BE',
});
from jquery-addresspicker.
you should submit a pull request
from jquery-addresspicker.
Done already ;-)
from jquery-addresspicker.
@sgruhier 👍 for this feature. I need.
Is @xurei pull request not ok to be merged?
from jquery-addresspicker.
I'll do it this week-end
But I can't just merge the PR because code has changed since then and I found few bugs.
But I'll use @Xurel code and do it.
from jquery-addresspicker.
@sgruhier mercy! 😄
from jquery-addresspicker.
@hugomaiavieira yes, it's okay to be merged :-)
from jquery-addresspicker.
Is it possible to do something like this:
"componentsFilter": "type:geocode",
?
from jquery-addresspicker.
Related Issues (20)
- IE9 + Later JQuery HOT 7
- jquery-addresspicker added to twitstrap resources HOT 1
- Getting this new error : not allowed by Access-Control-Allow-Origin. HOT 2
- Configure to find cities only. HOT 5
- Map Update by Address
- [enhancement] Add missing bower.json.
- jQuery UI - v1.8.24 HOT 1
- Reverse Geocoding to show current address before moving marker HOT 2
- New address picker based on typeahead HOT 3
- components filter does not work HOT 1
- Doesn't work on Firefox 12 HOT 3
- What if i have to use two markers in the same map?? HOT 5
- Problem with map inside Jquery Steps HOT 2
- Google Places HOT 4
- specification of an administrative area in a componentsFilter
- when make build with gulp bower files not working
- Regarding to timezone
- Is it possible to get suggestions without state/area
- How to make "Reverse Geocode" to be True by default? HOT 2
- Oops! Something went wrong. This page didn't load Google Maps correctly. See the JavaScript console for technical details. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jquery-addresspicker.