Advertisement
Guest User

Untitled

a guest
May 20th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.03 KB | None | 0 0
  1. addAllMarkersFromAPI() {
  2.  
  3. // MARKERY POBIERANE Z BAZY NIE MAJĄ LISTENERA, NIE MOŻNA URUCHOMIĆ DYMKA
  4.  
  5. let points = [];
  6.  
  7. let start_point;
  8. let end_point;
  9.  
  10. this.segmentPointsSet.forEach(element => {
  11. let markerStart;
  12. let markerEnd;
  13. start_point = element['start_point'];
  14. end_point = element['end_point'];
  15. const start_markerTemp: Marker = { lat: 0, lng: 0 };
  16. const end_markerTemp: Marker = { lat: 0, lng: 0 };
  17. start_markerTemp.lat = start_point.lat;
  18. start_markerTemp.lng = start_point.lng;
  19. end_markerTemp.lat = end_point.lat;
  20. end_markerTemp.lng = end_point.lng;
  21. points = element['points'];
  22.  
  23.  
  24. markerStart = new google.maps.Marker({
  25. position: start_markerTemp,
  26. map: this.googleMap,
  27. title: 'id: ' + start_point.id + ', latlng: ' + start_point.lat + ' ' + start_point.lng
  28. // tslint:disable-next-line:max-line-length
  29.  
  30. });
  31.  
  32.  
  33. const info = new google.maps.InfoWindow({
  34. content: '<html>' +
  35. '<head>' +
  36. '<style>' +
  37. 'p {' +
  38. 'color: blue;' +
  39. 'font-size:15px' +
  40. '}' +
  41. '.gm-style-iw {' +
  42. 'top: 0 !important;' +
  43. 'left: 10 !important;' +
  44. 'color:blue' +
  45. 'width:500px !important;' +
  46. 'height:50px !important;' +
  47. 'padding-left: 10px;' +
  48. 'margin:3px 6px 0px 0px;' +
  49. '}' +
  50. '</style>' +
  51. '</head>' +
  52. '<body>' +
  53. '<div class="gm-style-iw">' +
  54. '<p>' + 'ID: ' + start_point.id + ' LatLng: ' + start_point.lat + ' ' + start_point.lng + '</p>' +
  55. '</div>' +
  56. '</body>' +
  57. '</html>',
  58. });
  59.  
  60. markerStart.addListener('click', function () {
  61. info.open(this.googleMap, markerStart);
  62. markerStart.setIcon('http://maps.google.com/mapfiles/ms/icons/green-dot.png');
  63. });
  64.  
  65. this.markersListenerArray.push(markerStart);
  66.  
  67. markerEnd = new google.maps.Marker({
  68. position: end_markerTemp,
  69. map: this.googleMap,
  70. title: 'id: ' + end_point.id + ', latlng: ' + ' ' + end_point.lat + ' ' + end_point.lng,
  71. // tslint:disable-next-line:max-line-length
  72.  
  73. });
  74.  
  75.  
  76. const info2 = new google.maps.InfoWindow({
  77. content: '<html>' +
  78. '<head>' +
  79. '<style>' +
  80. 'p {' +
  81. 'color: blue;' +
  82. 'font-size:15px' +
  83. '}' +
  84. '.gm-style-iw {' +
  85. 'top: 0 !important;' +
  86. 'left: 10 !important;' +
  87. 'color:blue' +
  88. 'width:500px !important;' +
  89. 'height:50px !important;' +
  90. 'padding-left: 10px;' +
  91. 'margin:3px 6px 0px 0px;' +
  92. '}' +
  93. '</style>' +
  94. '</head>' +
  95. '<body>' +
  96. '<div class="gm-style-iw">' +
  97. '<p>' + 'ID: ' + end_point.id + ' LatLng: ' + end_point.lat + ' ' + end_point.lng + '</p>' +
  98. '</div>' +
  99. '</body>' +
  100. '</html>',
  101.  
  102. });
  103.  
  104. markerEnd.addListener('click', function () {
  105. info2.open(this.googleMap, markerEnd);
  106. markerEnd.setIcon('http://maps.google.com/mapfiles/ms/icons/green-dot.png');
  107. });
  108. this.markersListenerArray.push(markerEnd);
  109.  
  110. this.markersArray.push(start_markerTemp);
  111.  
  112. points.forEach(point => {
  113. const markerTemp: Marker = { lat: 0, lng: 0 };
  114. markerTemp.lat = point.lat;
  115. markerTemp.lng = point.lng;
  116. this.markersArray.push(markerTemp);
  117.  
  118. // marker = new google.maps.Marker({
  119. // position: markerTemp,
  120. // map: this.googleMap,
  121. // icon: 'http://maps.google.com/mapfiles/kml/pal4/icon49.png'
  122. // });
  123. });
  124.  
  125. this.markersArray.push(end_markerTemp);
  126. this.drawPath();
  127.  
  128. this.markersArray = [];
  129.  
  130.  
  131. });
  132.  
  133. console.log('MarkersListenerArray');
  134. console.table(this.markersListenerArray);
  135. console.log(this.markersArray);
  136.  
  137. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement