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