D
D
Dmitry2017-06-02 00:14:22
JavaScript
Dmitry, 2017-06-02 00:14:22

Why can't Yandex or Google map be initialized from an included js file like common.js?

Good evening. An interesting question arose. If you include the script of any of the specified maps in the head of the document, then it works, but if you take it out to a third-party file like common.js, it does not connect. Might be a stupid question, but why is that? Thank you.
I am posting this script:

ymaps.ready(init);
      var myMap, 
        myPlacemark;

      function init(){ 
        myMap = new ymaps.Map("map", {
          center: [53.677011,27.097172],
          zoom: 14,
          controls: ["zoomControl","geolocationControl"]
        }); 					
        var myPlacemark = new ymaps.Placemark([53.677011,27.097172], {}, {
          iconLayout: 'default#image',
          iconImageHref: 'images/i/map-mark.png',
          iconImageSize: [129,34],
          iconImageOffset:[-17, -64]
        });				
        myMap.geoObjects.add(myPlacemark);
      }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question