@bmlt-enabled/croutonjs 4.3.1 → 4.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/crouton-map.js CHANGED
@@ -349,24 +349,25 @@ function addControl(div,pos,cb) {
349
349
  q: query,
350
350
  limit: 5,
351
351
  format: 'json',
352
- addressdetails: 1
352
+ addressdetails: 1,
353
+ layer: "address"
353
354
  },
354
355
  params
355
356
  ),
356
357
  L.bind(function(data) {
357
- var results = [];
358
358
  if (data && data.length) {
359
- for (var i = data.length - 1; i >= 0; i--) {
360
- var bbox = data[i].boundingbox;
361
- for (var j = 0; j < 4; j++) bbox[j] = parseFloat(bbox[j]);
362
- results[i] = {
363
- icon: data[i].icon,
364
- name: data[i].display_name,
365
- bbox: L.latLngBounds([bbox[0], bbox[2]], [bbox[1], bbox[3]]),
366
- center: L.latLng(data[i].lat, data[i].lon),
367
- properties: data[i]
368
- };
369
- }
359
+ results = data.reduce(function(carry, d) {
360
+ if (!carry.find((item) => item.name === d.display_name)) {
361
+ var bbox = d.boundingbox.map((c) => parseFloat(c));
362
+ carry.push({
363
+ name: d.display_name,
364
+ bbox: L.latLngBounds([bbox[0], bbox[2]], [bbox[1], bbox[3]]),
365
+ center: L.latLng(d.lat, d.lon),
366
+ properties: d
367
+ });
368
+ }
369
+ return carry;
370
+ }, []);
370
371
  cb(results);
371
372
  } else {
372
373
  alert ( crouton.localization.getWord("address_lookup_fail") );