Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head></head>
- <meta http-equiv="content-type" content="text/html; charset=UTF-8">
- <meta charset="utf-8">
- <title></title>
- <style>
- *{
- margin: 0;
- padding: 0;
- }
- #map{
- height: 500px;
- width: 100%;
- }
- </style>
- <body>
- <div id="map"></div>
- <script>
- function initMap()
- {
- var infoBox = new google.maps.InfoWindow();
- var location = {lat: 51.533403, lng: 46.021206}; <!-- coordinats >
- var map = new google.maps.Map(document.getElementById("map"), {
- zoom:20,
- center: location,
- mapTypeId: google.maps.MapTypeId.ROADMAP});
- }
- initMap();
- </script>
- <script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCRymwuSu-hyqAYloKTusBQ6kNOSJTM0a8&callback=initMap">
- </script>
- <script type="text/javascript" src="jquery-3.3.1.min.js"></script>
- <script>
- var infowindow = new google.maps.InfoWindow();
- var marker, i;
- function getRequest() {
- console.log("good");
- $.ajax({
- url:'http://www.mocky.io/v2/5af5c5833100002c000025c8'
- , type:'GET'
- , dataType: "jsonp"
- , success: function(res) {
- for (var i = 0; i < res.length; i++){
- marker = new google.maps.Marker({
- position: new google.maps.LatLng(locations[i][1], locations[i][2]),
- map: map
- });
- google.maps.event.addListener(maker, 'click', (function(marker, i) {
- return function(){
- infowindow.setContent(locations[i][0]);
- infowindow.open(map, marker);
- }
- })(marker, i));
- }
- console.log("yes");
- }
- }
- , error: function(res) {
- console.log("NOOOOOOOOOOOOOOOOOOOOOOOOOOO");
- }
- });
- }
- getRequest();
- );
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement