×

Notice

The forum is in read only mode.
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: Address parsing incorrect

Address parsing incorrect 13 years 9 months ago #10109

  • Hubbitus
  • Hubbitus's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 7
  • Thank you received: 0
Parsing textual representation of address often do wrong results (at least for my country - Russia). Google provide this information also in object properties, I think better use it.

Patch provided:
Index: administrator/components/com_hotspots/views/edit/tmpl/default.php
===================================================================
--- administrator/components/com_hotspots/views/edit/tmpl/default.php (revision 88)
+++ administrator/components/com_hotspots/views/edit/tmpl/default.php (revision 91)
@@ -61,27 +61,34 @@
place = response.Placemark[0];
point = new GLatLng(place.Point.coordinates[1],
place.Point.coordinates[0]);
- addressfull = place.address;
- addresssplit = addressfull.split(\",\");
- streety = addresssplit[0];
- plzsplit = addresssplit[1].split(\" \");
- plz = plzsplit[1];
- town = plzsplit[2];
- country = addresssplit[2];

- document.getElementById('street').value=streety;
- document.getElementById('plz').value=plz;
- document.getElementById('town').value=town;
- document.getElementById('country').value=country;
- document.getElementById('gmlat').value=place.Point.coordinates[1];
- document.getElementById('gmlng').value=place.Point.coordinates[0];
+ var zip; // Zip not always set for each address, so we need search it
+ try{
+ \$each(
+ response.Placemark
+ ,function(el, idx){
+ if(el.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea && el.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.DependentLocality && el.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.DependentLocality.PostalCode){
+ zip = el.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.DependentLocality.PostalCode.PostalCodeNumber;
+ throw 'end';
+ }
+ }
+ )
+ }catch(e){}

- addnew.openInfoWindowHtml( '" . JTEXT::_('Street') . " ' + streety +
- '<br />' + '" . JTEXT::_('ZIP') . " ' + plz +
- '<br />' + '" . JTEXT::_('Town') . " ' + town +
- '<br />' + '" . JTEXT::_('Country') . " ' + country +
+ $('street').value = street = (place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.DependentLocality.Thoroughfare ? place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.DependentLocality.Thoroughfare.ThoroughfareName : 'undefined');
+ $('plz').value = zip;
+ $('town').value = place.AddressDetails.Country.AdministrativeArea.AdministrativeAreaName;
+ $('country').value = place.AddressDetails.Country.CountryName;
+ $('gmlat').value = place.Point.coordinates[1];
+ $('gmlng').value = place.Point.coordinates[0];
+
+ addnew.openInfoWindowHtml( '" . JTEXT::_('Street') . " ' + street +
+ '<br />' + '" . JTEXT::_('ZIP') . " ' + zip +
+ '<br />' + '" . JTEXT::_('Town') . " ' + place.AddressDetails.Country.AdministrativeArea.AdministrativeAreaName +
+ '<br />' + '" . JTEXT::_('Country') . " ' + place.AddressDetails.Country.CountryName +
'<br />' + '" . JTEXT::_('Gmlat') . " ' + place.Point.coordinates[0] +
- '<br />' + '" . JTEXT::_('Gmlng') . " ' + place.Point.coordinates[1] );
+ '<br />' + '" . JTEXT::_('Gmlng') . " ' + place.Point.coordinates[1]
+ );
}});
}
});

Address parsing incorrect 13 years 4 months ago #10793

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Away
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
Hey Hubbitus,
Yep, parsing the address doesn't bring the necessary results.
I spend the whole day yesterday trying to use the values returned from the geocoder.
The example that you are giving is going to work for russia, but not for USA or UK.
The geocoder returns the result in every possible way depending on the country - they use the xAL standard, but it is a big hassle trying to figure out in which country we have subadministrative area and in which we don't.
The information given here as example:
code.google.com/apis/maps/documentation/...vices.html#Geocoding
doesn't work in all cases,.

That is why I decided to leave the approach as it is for 1.0 stable. In 1.1 we plan to use the maps api v3 and there we can use the geocoder object and have reliable data returned - at least I hope so :)

Address parsing incorrect 13 years 4 months ago #10794

  • Hubbitus
  • Hubbitus's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 7
  • Thank you received: 0

Daniel Dimitrov wrote: In 1.1 we plan to use the maps api v3 and there we can use the geocoder object and have reliable data returned - at least I hope so

I like this approach. Good luck.

Address parsing incorrect 13 years 4 months ago #10796

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Away
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
Ah Hubbitus,
Did you write a review here already:
extensions.joomla.org/extensions/maps-a-...-locations/maps/9468
:)
Don't forget to do it :)
  • Page:
  • 1
Time to create page: 0.125 seconds