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, var bounds = data.geometry.bounds || data.geometry.viewport,
place = { place = {
components: data.address_components, components: data.address_components,
countryCode: Ox.getCountryCode(data.formatted_address), countryCode: getCountryCode(data.address_components),
east: bounds.getNorthEast().lng(), east: bounds.getNorthEast().lng(),
fullGeoname: getFullGeoname(data.address_components),
geoname: data.formatted_address, geoname: data.formatted_address,
id: '_' + Ox.uid(), id: '_' + Ox.uid(),
map: that, map: that,
name: data.formatted_address.split(', ')[0], name: data.formatted_address.split(', ')[0],
north: bounds.getNorthEast().lat(), north: bounds.getNorthEast().lat(),
south: bounds.getSouthWest().lat(), south: bounds.getSouthWest().lat(),
types: data.types, types: data.types.map(function(type) {
return Ox.toTitleCase(type.replace(/_/g, ' '));
}),
west: bounds.getSouthWest().lng() 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; return place;
} }

View file

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