Project

General

Profile

Task #6220

Story #6206: Plot data packages on map layer

Find JS library for centroid calculation

Added by ben leinfelder over 8 years ago. Updated over 8 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
Target version:
Start date:
11/15/2013
Due date:
% Done:

0%

Estimated time:

Description

Perhaps this will work for us.
https://github.com/netshade/spatial_query

Chris also mentioned Dave V. had written something up.

History

#1 Updated by Chris Jones over 8 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

#2 Updated by ben leinfelder over 8 years ago

  • translation missing: en.field_remaining_hours set to 0.0
  • Status changed from In Progress to Resolved
  • Description updated (diff)

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();

Also available in: Atom PDF