Project

General

Profile

Actions

Task #6220

closed

Story #6206: Plot data packages on map layer

Find JS library for centroid calculation

Added by ben leinfelder about 9 years ago. Updated about 9 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.

Actions #1

Updated by Chris Jones about 9 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

Actions #2

Updated by ben leinfelder about 9 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();

Actions

Also available in: Atom PDF