This commit is contained in:
rlx 2011-03-04 17:14:34 +00:00
parent 23eb7cd386
commit 73f5222b34
2 changed files with 30 additions and 3 deletions

View file

@ -9698,17 +9698,42 @@ requires
var bounds = data.geometry.bounds || data.geometry.viewport,
place = {
components: data.address_components,
countryCode: Ox.getCountryCode(data.formatted_address),
countryCode: getCountryCode(data.address_components),
east: bounds.getNorthEast().lng(),
fullGeoname: getFullGeoname(data.address_components),
geoname: data.formatted_address,
id: '_' + Ox.uid(),
map: that,
name: data.formatted_address.split(', ')[0],
north: bounds.getNorthEast().lat(),
south: bounds.getSouthWest().lat(),
types: data.types,
types: data.types.map(function(type) {
return Ox.toTitleCase(type.replace(/_/g, ' '));
}),
west: bounds.getSouthWest().lng()
};
function getCountryCode(components) {
countryCode = '';
Ox.forEach(components, function(component) {
if (component.types.indexOf('country') > -1) {
countryCode = component.short_name;
return false;
}
});
return countryCode;
}
function getFullGeoname(components) {
var country = false;
return components.map(function(component, i) {
var name = component.long_name;
if (i && components[i - 1].types.indexOf('country') > -1) {
country = true;
}
return !country && (
i == 0 || name != components[i - 1].long_name
) ? name : null;
}).join(', ')
}
return place;
}

View file

@ -48,6 +48,7 @@ $(function() {
countryCode: data.countryCode,
crossesDateline: data.crossesDateline,
east: data.east,
fullGeoname: data.fullGeoname,
geoname: data.geoname,
lat: data.lat,
lng: data.lng,
@ -64,7 +65,8 @@ $(function() {
}
}),
list = new Ox.TreeList({
data: []
data: [],
width: 256
})
panel = new Ox.SplitPanel({
elements: [