C5-8.3: maps script doesn't show map
Permalink
The following html works fine on its own, the map loads and shows:
But when I copy that into my block's view.php:
the map doesn't show up. However, if I inspect the element in the browser, the <div> is full of code. So, the script loads, but doesn't show up.
I load the script in the header in the controller:
and I checked it does load in the header.
Why doesn't the map show up? What's wrong?
Thank you.
<html> <head> <script src="https://api-maps.yandex.ru/2.1/?lang=ru_RU" type="text/javascript"></script> </head> <body> <div id="map"></div> <script type="text/javascript"> ymaps.ready(init); function init() { var myMap = new ymaps.Map("map", { center: [55.76, 37.64], zoom: 10 }); } </script>
But when I copy that into my block's view.php:
the map doesn't show up. However, if I inspect the element in the browser, the <div> is full of code. So, the script loads, but doesn't show up.
I load the script in the header in the controller:
public function on_start() { $html = $this->app->make('helper/html'); $this->addHeaderItem($html->javascript('https://api-maps.yandex.ru/2.1/?lang=ru_RU')); }
and I checked it does load in the header.
Why doesn't the map show up? What's wrong?
Thank you.
I thought I was gong mad...