Advertisement
kryuch

Untitled

May 25th, 2018
540
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head></head>
  4. <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  5. <meta charset="utf-8">
  6. <title></title>
  7. <style>
  8. *{
  9. margin: 0;
  10. padding: 0;
  11. }
  12. #map{
  13. height: 500px;
  14. width: 100%;
  15. }
  16. </style>
  17. <body>
  18.  
  19. <div id="map"></div>
  20.  
  21. <script>
  22. function initMap()
  23. {
  24. var infoBox = new google.maps.InfoWindow();
  25. var location = {lat: 51.533403, lng: 46.021206}; <!-- coordinats >
  26. var map = new google.maps.Map(document.getElementById("map"), {
  27. zoom:20,
  28. center: location,
  29. mapTypeId: google.maps.MapTypeId.ROADMAP});
  30. }
  31. initMap();
  32. </script>
  33. <script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCRymwuSu-hyqAYloKTusBQ6kNOSJTM0a8&callback=initMap">
  34. </script>
  35.  
  36. <script type="text/javascript" src="jquery-3.3.1.min.js"></script>
  37.  
  38. <script>
  39. var infowindow = new google.maps.InfoWindow();
  40. var marker, i;
  41.  
  42. function getRequest() {
  43. console.log("good");
  44. $.ajax({
  45. url:'http://www.mocky.io/v2/5af5c5833100002c000025c8'
  46. , type:'GET'
  47. , dataType: "jsonp"
  48. , success: function(res) {
  49. for (var i = 0; i < res.length; i++){
  50. marker = new google.maps.Marker({
  51. position: new google.maps.LatLng(locations[i][1], locations[i][2]),
  52. map: map
  53. });
  54. google.maps.event.addListener(maker, 'click', (function(marker, i) {
  55. return function(){
  56. infowindow.setContent(locations[i][0]);
  57. infowindow.open(map, marker);
  58. }
  59. })(marker, i));
  60. }
  61. console.log("yes");
  62. }
  63. }
  64. , error: function(res) {
  65.  
  66. console.log("NOOOOOOOOOOOOOOOOOOOOOOOOOOO");
  67. }
  68. });
  69. }
  70. getRequest();
  71. );
  72.  
  73. </script>
  74. </body>
  75. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement