From 4139e171ca4ca271b1c14ecb872db9a44cde9739 Mon Sep 17 00:00:00 2001 From: rolux Date: Thu, 5 Jul 2012 10:42:15 +0200 Subject: [PATCH] fix place type detection --- source/Ox.UI/js/Map/Map.js | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/source/Ox.UI/js/Map/Map.js b/source/Ox.UI/js/Map/Map.js index 8bcf239a..e1071745 100644 --- a/source/Ox.UI/js/Map/Map.js +++ b/source/Ox.UI/js/Map/Map.js @@ -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 } }); }