I can not get the script to work in Yii2 to get json data from the database. there is a file / modules/maps/views/object/objectsjson.php (simplified .., in general, data is taken from the database):
echo '{ "type": "FeatureCollection", "features": [ {"type": "Feature", "id": 0, "geometry": {"type": "Point", "coordinates": [55.831903, 37.411961]}, "properties": {"balloonContent": "Π‘ΠΎΠ΄Π΅ΡΠΆΠΈΠΌΠΎΠ΅ Π±Π°Π»ΡΠ½Π°", "clusterCaption": "ΠΡΠ΅ ΠΎΠ΄Π½Π° ΠΌΠ΅ΡΠΊΠ°", "hintContent": "Π’Π΅ΠΊΡΡ ΠΏΠΎΠ΄ΡΠΊΠ°Π·ΠΊΠΈ"}}, {"type": "Feature", "id": 1, "geometry": {"type": "Point", "coordinates": [55.763338, 37.565466]}, "properties": {"balloonContent": "Π‘ΠΎΠ΄Π΅ΡΠΆΠΈΠΌΠΎΠ΅ Π±Π°Π»ΡΠ½Π°", "clusterCaption": "ΠΡΠ΅ ΠΎΠ΄Π½Π° ΠΌΠ΅ΡΠΊΠ°", "hintContent": "Π’Π΅ΠΊΡΡ ΠΏΠΎΠ΄ΡΠΊΠ°Π·ΠΊΠΈ"}} ] }'; and there is a javascript that accesses this file (an example is taken from here ):
ymaps.ready(init); function init () { var myMap = new ymaps.Map('map', { center: [Ρenter1,Ρenter2], zoom: 1, type: 'yandex#satellite' }), objectManager = new ymaps.ObjectManager({ clusterize: true, gridSize: 32 }); myMap.geoObjects.add(objectManager); $.ajax({ url: "http://site.ru/basic/web/index.php?r=maps%2Fobject%2Fobjectsjson" }).done(function(data) { objectManager.add(data); }); } the output is empty .. but if you put this file in the web folder and register
$.ajax({ url: "objectsjson.php" }).done(function(data) { objectManager.add(data); }); then it works! In the controller, that's what?
public function actionObjectsjson() { return $this->render('objectsjson'); } Where is the mistake? Thank you in advance.