Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. bildMarkersForRoute: function (newMarkers) {
  2.             console.log("WEBPassport.Views.FishkaMaps:bildMarkersForRoute");
  3.             var $this = this;
  4.             $this.newMarkersRadius = new Array();
  5.  
  6.             function isCheckedparters(p) {
  7.                 var checked = false;
  8.  
  9.                 $this.arrSelectedPartners.forEach(function (partner_item, partner_i) {
  10.                     if (partner_item == p.partner.code) {
  11.                         checked = true;
  12.                         return false;
  13.                     }
  14.                 });
  15.  
  16.                 return checked;
  17.             }
  18.  
  19.             function isCheckedDescription(p) {
  20.                 var checked = false;
  21.  
  22.                 $this.arrSelectedDescription.forEach(function (desc_item, partner_i) {
  23.                     p.location.categoryCodes.forEach(function (code, partner_i) {
  24.                         if (desc_item.code == code) {
  25.                             checked = true;
  26.                             return false;
  27.                         }
  28.                     });
  29.                 });
  30.  
  31.                 return checked;
  32.             }
  33.  
  34.             if (newMarkers) {
  35.                 if ($this.distance == 0) {
  36.                     $this.newMarkersRadius = newMarkers;
  37.                 }
  38.                 else {
  39.                     $this.routeBoxes = $this.routeBoxer.box($this.routePath, $this.distance / 2);
  40.                     for (var i = 0; i < $this.routeBoxes.length; i++) {
  41.                         for (var j = 0; j < newMarkers.length; j++) {
  42.                             if ($this.routeBoxes[i].contains(newMarkers[j].getPosition()))
  43.                                 $this.newMarkersRadius.push(newMarkers[j]);
  44.                         }
  45.                     }
  46.                 }
  47.             }
  48.             else {
  49.                 if ($this.distance == 0) {
  50.                     for (var j = 0; j < $this.markers.length; j++) {
  51.                         if (isCheckedparters($this.markers[j]))
  52.                             $this.newMarkersRadius.push($this.markers[j]);
  53.                     }
  54.                 }
  55.                 else {
  56.                     // Convert the distance to box around the route from miles to km
  57.                     $this.routeBoxes = $this.routeBoxer.box($this.routePath, $this.distance / 2);
  58.                     for (var i = 0; i < $this.routeBoxes.length; i++) {
  59.                         for (var j = 0; j < $this.markers.length; j++) {
  60.                             if (($this.routeBoxes[i].contains($this.markers[j].getPosition()) && isCheckedparters($this.markers[j])) ||
  61.                                 ($this.routeBoxes[i].contains($this.markers[j].getPosition()) && isCheckedDescription($this.markers[j]))) {
  62.                                 $this.newMarkersRadius.push($this.markers[j]);
  63.                             }
  64.                         }
  65.                     }
  66.                 }
  67.             }
  68.             if ($this.markerCluster)
  69.                 $this.markerCluster.clearMarkers();
  70.  
  71.             $this.markerCluster = new MarkerClusterer($this.map, $this.newMarkersRadius, $this.mcOptions);
  72.  
  73.             google.maps.event.trigger($this.map, 'resize');
  74.         },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement