Task #6220
closedStory #6206: Plot data packages on map layer
Find JS library for centroid calculation
0%
Description
Perhaps this will work for us.
https://github.com/netshade/spatial_query
Chris also mentioned Dave V. had written something up.
Updated by Chris Jones about 11 years ago
- Status changed from New to In Progress
In the d1_dashboard, we were trying to plot all markers simultaneously, and therefore required an aggregation library that took in individual points, and calculating centroids on the client side would be a big task. In this use case, where we're only calculating centroids for, say, 100 markers, using Google's Map API might be the easiest. Try using the LatLngBounds class, which includes the getCenter() method, and only needs the SW and NE corners as arguments, which can be derived from the N, S, E, W bounding coordinates provided in the Solr index. See:
https://developers.google.com/maps/documentation/javascript/reference#LatLngBounds
Updated by ben leinfelder about 11 years ago
- Description updated (diff)
- Status changed from In Progress to Resolved
- translation missing: en.field_remaining_hours set to 0.0
Turns out Google Maps API has just the thing for us:
var latLngSW = new gmaps.LatLng(s, w); var latLngNE = new gmaps.LatLng(n, e); var bounds = new gmaps.LatLngBounds(latLngSW, latLngNE); var latLngCEN = bounds.getCenter();