예제 #1
0
파일: Adver.php 프로젝트: rocketyang/admap
 protected function getClusteringMarkers($zoom, $lat_max, $lat_min, $lng_min, $lng_max)
 {
     $number = 0;
     $multiplyNumber = 1 / 500 * pow(2.4, $zoom);
     $query = new Query();
     $query->from('{{%adver}}')->select(["COUNT(*) AS [[adver_count]]", "AVG(latitude) AS [[lat]]", "AVG(longitude) AS [[lng]]", "FORMAT([[latitude]] * {$multiplyNumber} , {$number}) AS [[g_lt]]", "FORMAT([[longitude]] * {$multiplyNumber} , {$number}) AS [[g_ln]]"]);
     $query->andWhere(['between', '[[latitude]]', $lat_min, $lat_max]);
     $query->andWhere(['between', '[[longitude]]', $lng_min, $lng_max]);
     $query->WHERE(['[[status]]' => self::STATUS_ACTIVE, 'lang' => ['*', Yii::$app->language]]);
     // adjust the query by adding the filters
     $query->andFilterWhere(['[[category_id]]' => $this->category_id]);
     $query->andFilterWhere(['[[country_id]]' => $this->country_id]);
     $query->andFilterWhere(['[[province_id]]' => $this->province_id]);
     $query->andFilterWhere(['[[city_id]]' => $this->city_id]);
     $query->andFilterWhere(['like', '[[title]]', $this->title]);
     $query->andFilterWhere(['like', '[[address]]', $this->address]);
     $query->groupBy(['[[g_lt]]', '[[g_ln]]']);
     return $this->mergeBubbles($zoom, $query->all());
 }