コード例 #1
0
ファイル: Geometry.php プロジェクト: katzz0/yii2-yandex-maps
 /**
  * Returns json
  * @return string
  */
 public function getJson()
 {
     $data = ['type' => $this->type, 'coordinates' => []];
     if (!count($this->points) && ($map = Api::getCurrentMap())) {
         $data['coordinates'] = new JsExpression($map->getId() . '.getCenter()');
     } elseif (count($this->points) === 1) {
         $data['coordinates'] = $this->points[0]->getCoordinates();
     } else {
         foreach ($this->points as $point) {
             $data['coordinates'][] = $point->getCoordinates();
         }
     }
     return Json::encode($data);
 }
コード例 #2
0
ファイル: Canvas.php プロジェクト: katzz0/yii2-yandex-maps
 /**
  * Register scripts for map control
  */
 private function registerScripts()
 {
     Api::registerApiFile($this->map);
     $js = "\nymaps.ready(function() {\n" . (string) $this->map . "\n});";
     \Yii::$app->view->registerJs($js, View::POS_READY);
 }