Yii2 and original google maps and places api


Can anyone help me with this? I have simple view page. I want to use google maps js api along with google places api. I don’t want to use any yii google extensions. So I’ve added this to my view.php:



//some code here

<div id="map"></div>

// rest of the code

Then to my myCode.js:

var map;

// Google Maps API

function initMap() {

    map = new google.maps.Map(document.getElementById('map'), {

    center: {lat: -34.397, lng: 150.644},

    zoom: 8



And nothing happens. Page renders ok, but my map doesn’t show.

I was looking for any topic, but all are about google extensions.

Can anyone help?

I’ve created empty page with this code and it works, but with Yii2 it doesn’t.

your code work. maybe the problem in css. try to add this in your css file:


Try and use ‘registerJs’ for the actual code, like described here: http://www.yiiframew…tml#registerJs()-detail.

You want that code to be evaluated on POS_READY (the default)