fix place type detection

This commit is contained in:
rolux 2012-07-05 10:42:15 +02:00
parent a0867f0da6
commit 4139e171ca

View file

@ -589,7 +589,7 @@ Ox.Map = function(options, self) {
if (place.bounds.equals(p.bounds)) { if (place.bounds.equals(p.bounds)) {
place = p; place = p;
exists = true; exists = true;
Ox.Break(); return false; // break
} }
}); });
if (!exists) { if (!exists) {
@ -782,7 +782,7 @@ Ox.Map = function(options, self) {
canContain(bounds, result.geometry.bounds || result.geometry.viewport) canContain(bounds, result.geometry.bounds || result.geometry.viewport)
) { ) {
callback(new Ox.MapPlace(parseGeodata(results[i]))); callback(new Ox.MapPlace(parseGeodata(results[i])));
Ox.Break(); return false; // break
} }
}); });
} else { } else {
@ -831,7 +831,7 @@ Ox.Map = function(options, self) {
Ox.forEach(self.options.places, function(place, i) { Ox.forEach(self.options.places, function(place, i) {
if (place.name == name) { if (place.name == name) {
position = i; position = i;
Ox.Break(); return false; // break
} }
}); });
return position; return position;
@ -847,7 +847,7 @@ Ox.Map = function(options, self) {
Ox.forEach(self.places, function(place) { Ox.forEach(self.places, function(place) {
if (place.selected) { if (place.selected) {
id = place.id; id = place.id;
Ox.Break(); return false; // break
} }
}); });
} }
@ -1083,7 +1083,7 @@ Ox.Map = function(options, self) {
Ox.forEach(components, function(component) { Ox.forEach(components, function(component) {
if (component.types.indexOf('country') > -1) { if (component.types.indexOf('country') > -1) {
countryCode = component.short_name; countryCode = component.short_name;
Ox.Break(); return false; // break
} }
}); });
return countryCode; return countryCode;
@ -1101,8 +1101,7 @@ Ox.Map = function(options, self) {
}).join(', '); }).join(', ');
} }
function getType(types) { function getType(types) {
Ox.Log('Map', 'getType', types) // see https://developers.google.com/maps/documentation/javascript/geocoding#GeocodingAddressTypes
// see http://code.google.com/apis/maps/documentation/javascript/services.html#GeocodingAddressTypes
var strings = { var strings = {
'country': ['country'], 'country': ['country'],
'region': ['administrative_area', 'colloquial_area'], 'region': ['administrative_area', 'colloquial_area'],
@ -1113,16 +1112,18 @@ Ox.Map = function(options, self) {
'street_address', 'street_number' 'street_address', 'street_number'
], ],
'building': [ 'building': [
'airport', 'establishment', 'floor', 'airport', 'floor', 'premise', 'room', 'subpremise'
'premise', 'room', 'subpremise' ],
] 'feature': ['natural_feature', 'park']
}, },
type = 'feature'; type;
function find(type) { function find(type) {
var ret; var ret;
Ox.forEach(types, function(v) { Ox.forEach(types, function(v) {
ret = Ox.startsWith(v, type); ret = Ox.startsWith(v, type);
ret && Ox.Break(); if (ret) {
return false; // break
}
}); });
return ret; return ret;
} }
@ -1130,12 +1131,14 @@ Ox.Map = function(options, self) {
Ox.forEach(values, function(value) { Ox.forEach(values, function(value) {
if (find(value)) { if (find(value)) {
type = key; type = key;
Ox.Break(); return false; // break
} }
}); });
type != 'feature' && Ox.Break(); if (type) {
return false; // break
}
}); });
return type; return type || 'feature';
} }
return place; return place;
} }
@ -1287,8 +1290,8 @@ Ox.Map = function(options, self) {
}) })
.css({ .css({
width: (scaleWidth - 16) + 'px' width: (scaleWidth - 16) + 'px'
}) });
Ox.Break(); return false; // break
} }
}); });
} }