Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Extract more address components: administrative_area_level_1, adminis…

…trative_area_level_2, postal_code, street_number, and route
  • Loading branch information...
commit fdb3dea7dad6e690590321bbe66c5a060a3ec92f 1 parent 539fd55
@chrisgibson chrisgibson authored
View
6 demos/demo.css
@@ -27,7 +27,7 @@ code {
}
label {
- width: 100px;
+ width: 200px;
float:left;
text-align:right;
margin:4px 10px 0 0;
@@ -45,7 +45,7 @@ p {
.ui-autocomplete-input, .input input {
border: none;
font-size: 14px;
- width: 300px;
+ width: 320px;
height: 24px;
margin-bottom: 5px;
padding-top: 2px;
@@ -78,4 +78,4 @@ p {
.input {
float:left;
-}
+}
View
14 demos/index.html
@@ -19,8 +19,13 @@
map: "#map",
lat: "#lat",
lng: "#lng",
+ country: '#country',
locality: '#locality',
- country: '#country'
+ administrativeAreaLevel1: '#administrative_area_level_1',
+ administrativeAreaLevel2: '#administrative_area_level_2',
+ postalCode: '#postal_code',
+ streetNumber: '#street_number',
+ route: '#route'
}
});
var gmarker = addresspickerMap.addresspicker( "marker");
@@ -54,8 +59,13 @@
<div>
<div class='input'>
<label>Address : </label> <input id="addresspicker_map" /> <br/>
- <label>Locality: </label> <input id="locality" disabled=disabled> <br/>
<label>Country: </label> <input id="country" disabled=disabled> <br/>
+ <label>Locality: </label> <input id="locality" disabled=disabled> <br/>
+ <label>Administrative Area Level 1: </label> <input id="administrative_area_level_1" disabled=disabled> <br/>
+ <label>Administrative Area Level 2: </label> <input id="administrative_area_level_2" disabled=disabled> <br/>
+ <label>Postal Code: </label> <input id="postal_code" disabled=disabled> <br/>
+ <label>Street Number: </label> <input id="street_number" disabled=disabled> <br/>
+ <label>Route: </label> <input id="route" disabled=disabled> <br/>
<label>Lat: </label> <input id="lat" disabled=disabled> <br/>
<label>Lng: </label> <input id="lng" disabled=disabled> <br/>
</div>
View
34 src/jquery.ui.addresspicker.js
@@ -29,8 +29,13 @@
map: false,
lat: false,
lng: false,
+ country: false,
locality: false,
- country: false
+ administrativeAreaLevel1: false,
+ administrativeAreaLevel2: false,
+ postalCode: false,
+ streetNumber: false,
+ route: false
}
},
@@ -66,8 +71,14 @@
this.lat = $(this.options.elements.lat);
this.lng = $(this.options.elements.lng);
- this.locality = $(this.options.elements.locality);
this.country = $(this.options.elements.country);
+ this.locality = $(this.options.elements.locality);
+ this.administrativeAreaLevel1 = $(this.options.elements.administrativeAreaLevel1);
+ this.administrativeAreaLevel2 = $(this.options.elements.administrativeAreaLevel2);
+ this.postalCode = $(this.options.elements.postalCode);
+ this.streetNumber = $(this.options.elements.streetNumber);
+ this.route = $(this.options.elements.route);
+
if (this.options.elements.map) {
this.mapElement = $(this.options.elements.map);
this._initMap();
@@ -141,11 +152,26 @@
}
this._updatePosition(address.geometry.location);
+ if (this.country) {
+ this.country.val(this._findInfo(address, 'country'));
+ }
if (this.locality) {
this.locality.val(this._findInfo(address, 'locality'));
}
- if (this.country) {
- this.country.val(this._findInfo(address, 'country'));
+ if (this.administrativeAreaLevel1) {
+ this.administrativeAreaLevel1.val(this._findInfo(address, 'administrative_area_level_1'));
+ }
+ if (this.administrativeAreaLevel2) {
+ this.administrativeAreaLevel2.val(this._findInfo(address, 'administrative_area_level_2'));
+ }
+ if (this.postalCode) {
+ this.postalCode.val(this._findInfo(address, 'postal_code'));
+ }
+ if (this.streetNumber) {
+ this.streetNumber.val(this._findInfo(address, 'street_number'));
+ }
+ if (this.route) {
+ this.route.val(this._findInfo(address, 'route'));
}
},
Please sign in to comment.
Something went wrong with that request. Please try again.