Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added support regional biasing of search results ala Google's ccTLD s…

…ystem. Fixes #2.
  • Loading branch information...
commit b89d4ae9f3da1f66f812b1b1a06169f78ee5a1ed 1 parent be67498
@palewire palewire authored
Showing with 9 additions and 3 deletions.
  1. +1 −0  .gitignore
  2. +8 −3 jquery.geocodify.js
View
1  .gitignore
@@ -0,0 +1 @@
+test.html
View
11 jquery.geocodify.js
@@ -5,9 +5,10 @@
var height = opts.height || 35;
var fontSize = opts.fontSize || "16px";
var buttonValue = opts.buttonValue || "GO";
+ var regionBias = opts.regionBias || null;
var onSelect = opts.onSelect || function(ele) {alert('Jump to: ' + ele.formatted_address)};
- var Geocode = function(id, callback) {
+ var Geocode = function(id, callback, regionBias) {
this.previousSearch = null;
this.google = new google.maps.Geocoder();
this.fetch = function(query, force) {
@@ -25,7 +26,11 @@
$("#" + id + "-input").css("border", "1px solid #9C9C9C");
return false;
}
- this.google.geocode({ 'address': query }, callback);
+ var params = { 'address': query };
+ if (regionBias) {
+ params['region'] = regionBias;
+ }
+ this.google.geocode(params, callback);
};
};
@@ -186,7 +191,7 @@
.appendTo($this);
// Bind our geocoding operation to the form
- var app = new Geocode($this.attr("id"), callback);
+ var app = new Geocode($this.attr("id"), callback, regionBias);
var input = $("#" + inputId);
var button = $("#" + buttonId);
setInterval(function(){app.fetch(input.val(), false)}, 250);
Please sign in to comment.
Something went wrong with that request. Please try again.