|
141 | 141 | self.allLocationsLoaded();
|
142 | 142 | }
|
143 | 143 | },
|
144 |
| - loadFeature: function(loc, iw){ |
| 144 | + loadFeature: function(loc, iw, ignoreDefaultArea){ |
145 | 145 | var self = this, f;
|
146 | 146 | var loaded = false;
|
| 147 | + ignoreDefaultArea = ignoreDefaultArea || false; |
| 148 | + |
147 | 149 | if(loc != null && loc.type != null){
|
148 | 150 | if (loc.type.toLowerCase() === 'point') {
|
149 | 151 | var ll = new google.maps.LatLng(Number(loc.coordinates[1]), Number(loc.coordinates[0]));
|
|
152 | 154 | position: ll,
|
153 | 155 | title: loc.name
|
154 | 156 | });
|
155 |
| - if (!self.defaultZoomArea || self.defaultZoomArea == loc.id) { |
| 157 | + if ((!self.defaultZoomArea || self.defaultZoomArea == loc.id) || ignoreDefaultArea) { |
156 | 158 | self.featureBounds.extend(ll);
|
157 | 159 | }
|
158 | 160 | self.addFeature(f, loc);
|
|
183 | 185 | this.allMarkers.push(markerMap);
|
184 | 186 | }
|
185 | 187 |
|
186 |
| - if (!self.defaultZoomArea || self.defaultZoomArea == loc.id) { |
| 188 | + if ((!self.defaultZoomArea || self.defaultZoomArea == loc.id) || ignoreDefaultArea) { |
187 | 189 | self.featureBounds.extend(ll);
|
188 | 190 | }
|
189 | 191 |
|
|
199 | 201 | });
|
200 | 202 | //set the extend of the map
|
201 | 203 | //console.log("f.getBounds()",f.getBounds());
|
202 |
| - if (!self.defaultZoomArea || self.defaultZoomArea == loc.id) { |
| 204 | + if ((!self.defaultZoomArea || self.defaultZoomArea == loc.id) || ignoreDefaultArea) { |
203 | 205 | self.featureBounds.extend(f.getBounds().getNorthEast());
|
204 | 206 | self.featureBounds.extend(f.getBounds().getSouthWest());
|
205 | 207 | }
|
|
219 | 221 | // flatten arrays to array of points
|
220 | 222 | points = [].concat.apply([], paths);
|
221 | 223 | // extend bounds by each point
|
222 |
| - if (!self.defaultZoomArea || self.defaultZoomArea == loc.id) { |
| 224 | + if ((!self.defaultZoomArea || self.defaultZoomArea == loc.id) || ignoreDefaultArea) { |
223 | 225 | $.each(points, function (i,obj) {self.featureBounds.extend(obj);});
|
224 | 226 | }
|
225 | 227 |
|
|
242 | 244 | // The bounding box of a point is a linestring with two points
|
243 | 245 | pointArray = [pointArray[0], pointArray[1], pointArray[0], pointArray[1]];
|
244 | 246 | }
|
245 |
| - if (!self.defaultZoomArea || self.defaultZoomArea == loc.id) { |
| 247 | + if ((!self.defaultZoomArea || self.defaultZoomArea == loc.id) || ignoreDefaultArea) { |
246 | 248 | self.featureBounds.extend(new google.maps.LatLng(pointArray[1].split(" ")[1], pointArray[1].split(" ")[0]));
|
247 | 249 | self.featureBounds.extend(new google.maps.LatLng(pointArray[3].split(" ")[1], pointArray[3].split(" ")[0]));
|
248 | 250 | }
|
|
276 | 278 | iw = new google.maps.InfoWindow({maxWidth: 360});
|
277 | 279 | }
|
278 | 280 |
|
| 281 | + // List of features sometimes does not contain default zoom area. Hence map zoom to an extent not containing |
| 282 | + // sites. The below setting tells loadFeature to ignore the default zoom area check and add site to extent |
| 283 | + // calculation. |
| 284 | + var defaultArea = $.grep(features, function (loc) { |
| 285 | + return loc.id == self.defaultZoomArea; |
| 286 | + }), |
| 287 | + ignoreDefaultArea = defaultArea.length === 0; |
| 288 | + |
| 289 | + |
279 | 290 | $.each(features, function (i,loc) {
|
280 | 291 | //console.log('Loading feature with type:' + loc.type + "|" + loc.latitude);
|
281 | 292 | if(loc != null){
|
282 | 293 |
|
283 |
| - self.loadFeature(loc, iw); |
| 294 | + self.loadFeature(loc, iw, ignoreDefaultArea); |
284 | 295 | //self.locationLoaded();
|
285 | 296 | }
|
286 | 297 | });
|
|
0 commit comments