Reputation: 69
I have a projet based on Mapbox GL for which I must locate people by latitude and longitude and group them by continent on a world map.
Data of each member are coming from a MySQL database. I have a value attribute called continent for each line : for example, members from Europe have continent=1, members from North America have continent=2.
My question is simple (but the answer maybe not): how to group members in cluster (with number of members) for each continent?
My map operates fine, but clusters are calculated randomly by locations. I've looked for the clusterProperties function, but I don't understand how it works.
Calling data:
$result=mysqli_query($cnx,"SELECT * members where onair='1' ORDER BY ident");
$data="{ \"type\": \"FeatureCollection\",\"features\": [";
while($res=mysqli_fetch_object($result))
{
$data.="{ type: 'Feature', geometry: { type: 'Point', coordinates: [$res->longitude, $res->latitude] }, properties: { \"ident\":\"$res->ident\",\"continent\":\"$res->continent\",\"nom\":\"$res->nom\",\"ville\":\"$res->ville\" } },";
}
$data.="]};";
Loading map:
map.addSource('data', {
type: 'geojson',
data: members,
cluster: true,
clusterMaxZoom: 14,
clusterRadius: 50, clusterProperties: { ? }
});
Upvotes: 0
Views: 25