A
A
Anastasia Sila2014-11-19 17:00:05
JavaScript
Anastasia Sila, 2014-11-19 17:00:05

How to update/remove markers on the map that are set by ajax?

The crux of the matter is this.
There is a map. The coordinates of objects are taken from the database and placed with marks on the map, and all this without updating, because it was done on ajax.
Now it would be necessary to fasten the following functionality: when changing the coordinates of objects in the database, it is necessary to change their marks on the map. I made a timer and ajax that calls the php script, which in turn returns a function call with coordinates taken from the database

ShowObjectLocationAndState(" . $data['CoordLatitude'] . ", " . $data['CoordLongitude'].",\"" . $data['Description'] . "\", \"OK\")

As a result, instead of the old label in a new place, we get another label for an existing object. How to organize the label move function? Or do you first need to delete all the labels needed for the update, and then re-arrange them?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
Gosha Mann, 2014-11-19
@IgorMann

You're right - it doesn't make sense to move. Recreate the JS object and add labels to it.

M
miki131, 2014-12-25
@miki131

If there are few marks, then just clear the map, and re-add marks to it.
Otherwise, keep all labels in a hash, and when you get new coordinates from the base, update the label
point.geometry.setCoordinates(newLocation)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question