Topic: mass markers from a database

Topic: mass markers from a data base
hi im a noob, treat me gently.
i will try to explain myself and my need as fully as i can, i have no idea how to achieve it, but im willing to learn

i want to create a global map, as users register to my app,  i want them to be become discoverable/visable to other users.

when i show the map i want the user to be findable and to be able to find all other users withing x radius, but the user can pan the map to greater distances to find people further away.
like the map in snap chat, except my users long lat will rarely change the idea being they activate the gps and save the long lat when they are happy with their location making the marker pretty much permanent

so as users join i need to update the map to add their marker, but i also need to be able to update their map to contain the markers of the pre existing users,

no idea of the best way to keep uptodate list of all  longlats,and corresponding marker ids.

i also want to suggest friends within 15 miles, so i need to gather a list of all markers with 15miles of the users long lat,is there a pre build function for distance by radius

i have played with the demo scenes, i have looked at the api. but i have no idea where to start,
any help and direction would be greatly appreciated

Re: mass markers from a database

Hello.

Your task is not so simple and trivial as it may seem.

1.SQL:
You can not calculate the distance on the client side, because if you have several thousand users, this will kill the performance of your server and each client.
So the distance calculation should be done on the server side.
More precisely, the selection from SQL should be based on the distance.
Right distance calculation is an expensive method that will kill your server.

How to work around this:
You need to additionally store the user's coordinates in the Mercator projection (x: 0.0-1.0, y: 0.0-1.0).
In this case, you can greatly optimize the calculation of the distance:
D^2 = (cx - mx) * (cx - mx) + (cy-my) * (cy-my)
Where cx and cy are the coordinates of the central point in the Mercator projection, mx and my are the coordinates of the user in the Mercator projection.
R = 15 miles = 0.000601743742710974
R^2 = 3.62095531891811E-07
If R^2 < D^2, then the user in the specified radius.

To not work with such small numbers you can use (for example) zoom = 10.
Formulas for converting coordinates to the Mercator projection can be found in OnlineMapsProjectionSphericalMercator.

2. Online Maps:
When you receive a response from your server, you need to create new markers, update the positions of existing markers, and remove the non-existing markers.
OnlineMaps.markers, OnlineMaps.AddMarker, OnlineMaps.RemoveMarker, OnlineMapsMarkerBase.SetPosition.
You can store the marker ID (and any other information) in OnlineMapsMarkerBase.customData.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: mass markers from a database

many thanks for your help and direction,
i will be taking your advice and implementing as you say on the server,
you have filled many blanks already,
thanks again