L
L
lolka022020-05-29 10:08:19
PHP
lolka02, 2020-05-29 10:08:19

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
                ]
            ]];


but something tells me that I need to redo it, since objects are re-selected every time they enter this area and even with a smaller number (conditionally 10k) it already starts to slow down sometimes and even give out a 500 error

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question