Advertisement
Guest User

Untitled

a guest
Sep 13th, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. for (i=0; i < place.address_components.length; i++) {
  2. comp = place.address_components[i];
  3. // State
  4. if (!location.details.State && comp.types.indexOf('administrative_area_level_1') !== -1) {
  5. location.details.State = comp.short_name;
  6. }
  7. // City
  8. else if (!location.details.City && comp.types.indexOf('locality') !== -1) {
  9. location.details.City = comp.long_name;
  10. }
  11. // Zip
  12. else if (!location.details.Zip && comp.types.indexOf('postal_code') !== -1) {
  13. location.details.Zip = comp.long_name;
  14. }
  15. // Street Name
  16. else if (!location.details.Street.Name && comp.types.indexOf('route') !== -1) {
  17. location.details.Street.Name = comp.long_name;
  18. }
  19. // Street Number
  20. else if (!location.details.Street.Number && comp.types.indexOf('street_number') !== -1) {
  21. location.details.Street.Number = comp.long_name;
  22. }
  23. // Apt
  24. else if (!location.details.Apt && comp.types.indexOf('subpremise') !== -1) {
  25. location.details.Apt = comp.long_name;
  26. }
  27. }
  28. location.details.Street = (location.details.Street.Number + ' ' +location.details.Street.Name).trim();
  29. if (!location.details.Street) {
  30. location.details.Street = location.formatted_address_line1;
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement