Answer the question
In order to leave comments, you need to log in
How to optimize the display of objects on the Yandex map?
Now the output of objects is implemented using the RemoteObjectManager
on the server, a request is sent ../tile?bbox=41.1704,0.0000,66.6535,112.5000&zoom=5&callback=id_1590734764252265 there are a
lot of objects and every time the map state changes, a request is made by coordinates to select objects
$bbox = explode(',', Yii::$app->request->get('bbox'));
$query = Object::find()
->select('latitude, longitude')
->andFilterWhere(['>', 'latitude', $bbox[0]])
->andFilterWhere(['<', 'latitude', $bbox[2]])
->andFilterWhere(['>', 'longitude', $bbox[1]])
->andFilterWhere(['<', 'longitude', $bbox[3]]);
$models = $query->all();
$objects = [];
foreach ($models as $model) {
$objects[] = ..; //данные метки
}
return [
'callback' => '...'
'data' => [
'error' => null,
'data' => [
"type" => "FeatureCollection",
"features" => $objects
]
]];
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question