Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.67 KB | None | 0 0
  1. var latLngPath = [];
  2.  
  3. var latlng = new google.maps.LatLng(eventLocation.sender.split(",")[0], eventLocation.sender.split(",")[1]);
  4. // var map = new google.maps.Map(this.gmapElement.nativeElement, {
  5. // center: latlng,
  6. // zoom: 4
  7. // });
  8.  
  9.  
  10. var mapProp = {
  11. center: new google.maps.LatLng(eventLocation.sender.split(",")[0], eventLocation.sender.split(",")[1]),
  12. zoom: 4
  13. // mapTypeId: google.maps.MapTypeId.HYBRID // also use ROADMAP,SATELLITE or TERRAIN
  14. };
  15.  
  16. this.eventmap = new google.maps.Map(this.gmapElementevent.nativeElement, mapProp);
  17. var marker = new google.maps.Marker({ position: mapProp.center });
  18. marker.setMap(this.eventmap);
  19.  
  20. var infowindow = new google.maps.InfoWindow();
  21.  
  22. var i;
  23.  
  24. for (i = 0; i < locations.length; i++) {
  25. var latLng = new google.maps.LatLng(locations[i][0].split(",")[0], locations[i][0].split(",")[1]);
  26. latLngPath.push(latLng);
  27. marker = new google.maps.Marker({
  28. map: this.eventmap,
  29. // data: data['data'],
  30. position: new google.maps.LatLng(locations[i][0].split(",")[0], locations[i][0].split(",")[1]),
  31. draggable: false,
  32. anchorPoint: new google.maps.Point(0, -29)
  33. });
  34. google.maps.event.addListener(marker, 'click', (function (marker, i) {
  35.  
  36. return function () {
  37. var addressLocation;
  38. console.log("marker", marker);
  39. if (locations[i][0].split(",")[0] === locations[i][1].split(",")[0] && locations[i][0].split(",")[1] === locations[i][1].split(",")[1]) {
  40. addressLocation = locations[i][2];
  41. var iwContent = '<span> <b>Event Id : </b> <label class="text-primary">' + data['data'].eventExtId + ' <label></span><br />' +
  42. '<span> <b>Event Type : </b> <label class="text-primary">' + data['data'].eventType + ' <label></span><br />' +
  43. '<span> <b>Event Date : </b> <label class="text-primary">' + eventInformation.eventDateTime1 + ' <label></span><br />' +
  44. '<span> <b>Location : </b> <label class="text-primary">' + data['data'].location + ' <label></span>';
  45. infowindow.setContent(iwContent);
  46. infowindow.open(this.eventmap, marker);
  47. marker.setMap(this.eventmap)
  48. } else {
  49. addressLocation = locations[i][2];
  50. var iwContent = '<span> <b>Location : </b> <label class="text-primary">' + addressLocation + '<label></span><br />';
  51. infowindow.setContent(iwContent);
  52. infowindow.open(this.eventmap, marker);
  53. marker.setMap(this.eventmap)
  54. }
  55. }
  56. })(marker, i));
  57. }
  58.  
  59. var flightPath = new google.maps.Polyline({
  60. path: latLngPath,
  61. strokeColor: 'red',
  62. strokeOpacity: 1,
  63. strokeWeight: 4,
  64. zIndex: 300,
  65. icons: [{
  66. icon: {
  67. path: google.maps.SymbolPath.FORWARD_CLOSED_ARROW,
  68. strokeColor: 'black',
  69. fillOpacity: 1,
  70. scale: 3
  71. },
  72. repeat: '100px',
  73. offset: '100%'
  74. }],
  75. map: this.eventmap
  76. });
  77. flightPath.setMap(this.eventmap);
  78. var lastLatLng = latLngPath.slice(-1)[0];
  79. latLngPath = [];
  80. latLngPath.push(lastLatLng);
  81. marker.setMap(this.eventmap);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement