diff --git a/build/js/ox.ui.js b/build/js/ox.ui.js index 46ba0fc3..fe720ca6 100644 --- a/build/js/ox.ui.js +++ b/build/js/ox.ui.js @@ -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; } diff --git a/demos/map/js/map.js b/demos/map/js/map.js index 7623cb25..bf2adfa1 100644 --- a/demos/map/js/map.js +++ b/demos/map/js/map.js @@ -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: [