Advertisement
Guest User

Untitled

a guest
Jan 19th, 2017
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.64 KB | None | 0 0
  1. <!DOCTYPE html >
  2. <head>
  3. <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
  4. <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
  5. <title>L3 CARDS</title>
  6. <style>
  7. /* Always set the map height explicitly to define the size of the div
  8. * element that contains the map. */
  9. #map {
  10. height: 50%;
  11. width: 50%;
  12. }
  13. /* Optional: Makes the sample page fill the window. */
  14. html, body {
  15. height: 100%;
  16. width: 100%;
  17. margin: 0;
  18. padding: 0;
  19. }
  20. </style>
  21. </head>
  22.  
  23. <body>
  24. <div id="map"></div>
  25.  
  26. <script>
  27. var customLabel = {
  28. 1: {
  29. label: 'A'
  30. },
  31. 2: {
  32. label: 'I'
  33. },
  34. 3: {
  35. label: 'L'
  36. },
  37. 4: {
  38. label: 'R'
  39. },
  40. 5: {
  41. label: 'G'
  42. }
  43. };
  44.  
  45. function initMap() {
  46. var map = new google.maps.Map(document.getElementById('map'), {
  47. center: new google.maps.LatLng(45.3791021, -122.7613788),
  48. zoom: 15
  49. });
  50. var infoWindow = new google.maps.InfoWindow;
  51.  
  52. // Change this depending on the name of your PHP or XML file
  53. downloadUrl('maptest2.php', function(data) {
  54. var xml = data.responseXML;
  55. var markers = xml.documentElement.getElementsByTagName('marker');
  56. Array.prototype.forEach.call(markers, function(markerElem) {
  57. var id = markerElem.getAttribute('id');
  58. var reporttype = markerElem.getAttribute('reporttype');
  59. var propertyname = markerElem.getAttribute('propertyname');
  60. var point = new google.maps.LatLng(
  61. parseFloat(markerElem.getAttribute('lat')),
  62. parseFloat(markerElem.getAttribute('lng')));
  63. var infowincontent = document.createElement('div');
  64. var strong = document.createElement('strong');
  65. strong.textContent = propertyname
  66. infowincontent.appendChild(strong);
  67. infowincontent.appendChild(document.createElement('br'));
  68.  
  69. var text = document.createElement('text');
  70. text.textContent = propertyname
  71. infowincontent.appendChild(text);
  72. var icon = customLabel[reporttype] || {};
  73. var marker = new google.maps.Marker({
  74. map: map,
  75. position: point,
  76. label: icon.label
  77. });
  78. marker.addListener('click', function() {
  79. infoWindow.setContent(infowincontent);
  80. infoWindow.open(map, marker);
  81. });
  82. });
  83. });
  84. }
  85.  
  86.  
  87.  
  88. function downloadUrl(url, callback) {
  89. var request = window.ActiveXObject ?
  90. new ActiveXObject('Microsoft.XMLHTTP') :
  91. new XMLHttpRequest;
  92.  
  93. request.onreadystatechange = function() {
  94. if (request.readyState == 4) {
  95. request.onreadystatechange = doNothing;
  96. callback(request, request.status);
  97. }
  98. };
  99.  
  100. request.open('GET', url, true);
  101. request.send(null);
  102. }
  103.  
  104. function doNothing() {}
  105. </script>
  106. <script async defer
  107. src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAdgJ2anfhIkR3ZgrcLA5MD1RnR0256nK8&callback=initMap">
  108. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement