R
R
rusline2017-10-15 12:50:41
JavaScript
rusline, 2017-10-15 12:50:41

How can I see what the problem is when displaying the yandex map?

I have such a problem that I use node js and the map is not displayed when outputting, but let's say this is an example, it works approximately https://jsfiddle.net/rusline/Lhwmdmqg/
But on local hosting, it's not clear what the problem is, as if an error is indicated in the browser, but it does not display which nominal error does not display.
As I implemented on the node, I generated the
views/layout.pug application

doctype html
html
  head
    title= title
    link(rel='stylesheet', href='/stylesheets/style.css')
    script(src='/javascripts/yandex.js', type='text/javascript')
    script(src='https://api-maps.yandex.ru/2.1/?lang=ru_RU', type='text/javascript')
  body
    block content

In views/index.pug
extends layout
block content
  h1= title
  p Welcome to #{title}
  input(type="text")
  div#map(style="width: 600px; height: 400px")

public/javascripts/yandex.js
ymaps.ready(init);
let myMap,
    myPlacemark;

function init(){
    myMap = new ymaps.Map("map", {
        center: [55.76, 37.64],
        zoom: 7
    });

    myPlacemark = new ymaps.Placemark([55.76, 37.64], {
        hintContent: 'Москва!',
        balloonContent: 'Столица России'
    });

    myMap.geoObjects.add(myPlacemark);
}

And here that deduces 59e32f3f3e583114439702.png
But when you register in the console ymaps.ready (init); then everything is displayed this map
59e32fa5e041c049587608.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2017-10-15
@rusline

Well, here you have some kind of error in the console. 146% what it says Swap the script connection first - yours should be loaded after the maps script (or should be wrapped in DOMContentLoaded). ymaps.ready is not a function

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question