Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for (i=0; i < place.address_components.length; i++) {
- comp = place.address_components[i];
- // State
- if (!location.details.State && comp.types.indexOf('administrative_area_level_1') !== -1) {
- location.details.State = comp.short_name;
- }
- // City
- else if (!location.details.City && comp.types.indexOf('locality') !== -1) {
- location.details.City = comp.long_name;
- }
- // Zip
- else if (!location.details.Zip && comp.types.indexOf('postal_code') !== -1) {
- location.details.Zip = comp.long_name;
- }
- // Street Name
- else if (!location.details.Street.Name && comp.types.indexOf('route') !== -1) {
- location.details.Street.Name = comp.long_name;
- }
- // Street Number
- else if (!location.details.Street.Number && comp.types.indexOf('street_number') !== -1) {
- location.details.Street.Number = comp.long_name;
- }
- // Apt
- else if (!location.details.Apt && comp.types.indexOf('subpremise') !== -1) {
- location.details.Apt = comp.long_name;
- }
- }
- location.details.Street = (location.details.Street.Number + ' ' +location.details.Street.Name).trim();
- if (!location.details.Street) {
- location.details.Street = location.formatted_address_line1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement