I'm creating an app using a map and I have to place points on it. The problem is that when the points are nearby, the user can't see the difference. So, I need to regroup the points.
I receive JSONs like that:
[{"id": "1", "x": 253, "y": 144},
{"id": "2", "x": 142, "y": 355},
{"id": "3", "x": 175, "y": 330},
{"id": "4", "x": 140, "y": 5},
{"id": "5", "x": 307, "y": 306},
{"id": "6", "x": 233, "y": 304},
{"id": "7", "x": 212, "y": 163},
{"id": "8", "x": 202, "y": 163},
{"id": "9", "x": 204, "y": 171}]
And i need to regroup point with 20px difference in biggest point with coord of the average of all other points. It's deal a JSON like that:
[{"id": ["1"], "x": 253, "y": 144},
{"id": ["2"], "x": 142, "y": 355},
{"id": ["3"], "x": 175, "y": 330},
{"id": ["4"], "x": 140, "y": 5},
{"id": ["5"], "x": 307, "y": 306},
{"id": ["6"], "x": 233, "y": 304},
{"id": ["7","8","9"], "x": 206, "y": 165}]
I just need an algorithm to help me to build my own code.
Thank you for all help you can give to me.