javascript - Google Maps API loads from html file, but not on local host -


i trying connect google maps api localhost through angularjs application map not appear , map request not reach google. javascript file being found html, , test1 being outputted in console, initmap not being called , test2 not outputted. expect failing because https connection not being made google.

when open html file in browser, map loads fine when run on localhost, nothing comes up.

here html code:

<script src="client/services/maps.client.services.map.js"></script> <script src="https://maps.googleapis.com/maps/api/js?key={{api_key}}&callback=initmap"></script> 

and javascript (map.js):

console.log('test1'); function initmap() {   console.log('test2');    //markers   var markers = [       ['cardiff', 51.4539, -3.1694, 'city/cardiff'],       ['swansea', 51.6148, -3.92927895, 'city/swansea']   ];    // initialise map   var map = new google.maps.map(document.getelementbyid('map'), {     zoom: 10,     center: {lat: 51.4539, lng: -3.1694}   });    var bounds = new google.maps.latlngbounds();   for( = 0; < markers.length; i++ ) {     // plot pin each place     var position = new google.maps.latlng(markers[i][1], markers[i][2]);     bounds.extend(position);     marker = new google.maps.marker({       position: position,       map: map,       title: markers[i][0]     });      google.maps.event.addlistener(marker, 'click', (function(marker, i) {       return function() {         window.location.href = markers[i][3];       }     })(marker, i));   }    // zoom pins in view   map.fitbounds(bounds); } 

does understand why initmap function not being called?

change order of script tags

<script src="https://maps.googleapis.com/maps/api/js?key={{api_key}}&callback=initmap"></script> <script src="client/services/maps.client.services.map.js"></script> 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -