I’m trying to find right (or the best) solution for following question:
Say, i have a google map (it’s not matter actually what kind of map) where people can create and delete markers. Any user can look at the map and i know bounds of square which user looks now. So if somebody else creates marker on this square, i need to show it on the map immediatelly. For it i’m going to use websockets. But the question is not in a technical side but regarding to logic. What is the best way to send marker’s data to user? Should i store somehow current bounds of showed location? I don’t want to send new marker to all users because they may not need it, i want to send only to those who look at that square. Or i have to have producer who will be giving this information to consumers?
Sorry if i’ve written confusing stuff, ask me in case if something unclear. Thanks for your suggestions.
Keep track of your currently connected users’ map bounds. As they pan the map, make sure the server is updated with these bounds.
When a new point is added, on the server-side, loop through each connection and check if the coordinate is within those bounds. If it is, send the new marker.