From ef285150ee254661b9e93220f71177589eea903b Mon Sep 17 00:00:00 2001 From: Brandon Tilley Date: Mon, 23 Dec 2013 22:08:03 -0800 Subject: [PATCH] Reverse the order of `lat` and `lng` parameters of the `add` method of the `pings` plugin --- CHANGELOG.md | 2 ++ dist/planetaryjs-noplugins.js | 2 +- dist/planetaryjs.js | 17 +++++++++++++---- dist/planetaryjs.min.js | 2 +- site/public/documentation/builtin_pings.md | 15 ++++++++++++--- site/public/documentation/faq.md | 8 ++++++++ site/public/examples/quake.ejs | 2 +- site/public/examples/quake/quake.js | 2 +- site/public/examples/rotating.ejs | 2 +- site/public/examples/rotating.js | 2 +- site/public/js/homepage.js | 2 +- site/public/js/lib/planetaryjs.min.js | 2 +- src/plugins.js | 15 ++++++++++++--- 13 files changed, 55 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 29b3e57..f78cff9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +* Reverse the order of `lat` and `lng` parameters of the `add` method of the `pings` plugin + v0.2.2 ------ diff --git a/dist/planetaryjs-noplugins.js b/dist/planetaryjs-noplugins.js index 47b0ebd..a08c2bb 100644 --- a/dist/planetaryjs-noplugins.js +++ b/dist/planetaryjs-noplugins.js @@ -2,7 +2,7 @@ * Copyright (c) 2013 Brandon Tilley * * Released under the MIT license - * Date: 2013-12-23T23:11:47.627Z + * Date: 2013-12-24T06:07:53.830Z */ (function (root, factory) { if (typeof define === 'function' && define.amd) { diff --git a/dist/planetaryjs.js b/dist/planetaryjs.js index 6625b2e..61b8413 100644 --- a/dist/planetaryjs.js +++ b/dist/planetaryjs.js @@ -2,7 +2,7 @@ * Copyright (c) 2013 Brandon Tilley * * Released under the MIT license - * Date: 2013-12-23T23:11:47.446Z + * Date: 2013-12-24T06:07:53.694Z */ (function (root, factory) { if (typeof define === 'function' && define.amd) { @@ -258,13 +258,22 @@ planetaryjs.plugins.pings = function(config) { var pings = []; + var config = config || {}; - var addPing = function(lat, lng, options) { + var addPing = function(lng, lat, options) { var options = options || {}; options.color = options.color || config.color || 'white'; - options.ttl = options.ttl || config.ttl || 2000; options.angle = options.angle || config.angle || 5; - pings.push({ lat: lat, lng: lng, time: new Date(), options: options }); + options.ttl = options.ttl || config.ttl || 2000; + var ping = { time: new Date(), options: options }; + if (config.latitudeFirst) { + ping.lat = lng; + ping.lng = lat; + } else { + ping.lng = lng; + ping.lat = lat; + } + pings.push(ping); }; var drawPings = function(planet, context, now) { diff --git a/dist/planetaryjs.min.js b/dist/planetaryjs.min.js index 541df69..e8636c4 100644 --- a/dist/planetaryjs.min.js +++ b/dist/planetaryjs.min.js @@ -1,2 +1,2 @@ /*! Planetary.js 0.2.2 | (c) 2013 Brandon Tilley | Released under MIT License */ -!function(n,t){"function"==typeof define&&define.amd?define(["d3","topojson"],t):"object"==typeof exports?module.exports=t(require("d3"),require("topojson")):n.planetaryjs=t(n.d3,n.topojson,n)}(this,function(n,t,o){"use strict";var e=null;o&&(e=o.planetaryjs);var i=[],r=function(t,o,e){n.timer(function(){t.context.clearRect(0,0,o.width,o.height);for(var n=0;n=o.onInit.length?r(n,t,o):i(l)};i(l)}else r(n,t,o)},u=function(n,t,o,e){l(n,o),n.canvas=t,n.context=t.getContext("2d"),a(n,t,e)},c={plugins:{},noConflict:function(){return o.planetaryjs=e,c},loadPlugin:function(n){i.push(n)},planet:function(){var t=[],o={onInit:[],onDraw:[]},e={plugins:{},draw:function(n){u(e,n,t,o)},onInit:function(n){o.onInit.push(n)},onDraw:function(n){o.onDraw.push(n)},loadPlugin:function(n){t.push(n)},withSavedContext:function(n){if(!this.context)throw new Error("No canvas to fetch context for");this.context.save(),n(this.context),this.context.restore()}};return e.projection=n.geo.orthographic().clipAngle(90).precision(0),e.path=n.geo.path().projection(e.projection),e}};return c.plugins.topojson=function(t){return function(o){o.plugins.topojson={},o.onInit(function(e){if(t.world)o.plugins.topojson.world=t.world,setTimeout(e,0);else{var i=t.file||"world-110m.json";n.json(i,function(n,t){if(n)throw new Error("Could not load JSON "+i);o.plugins.topojson.world=t,e()})}})}},c.plugins.oceans=function(n){return function(t){t.onDraw(function(){t.withSavedContext(function(o){o.beginPath(),t.path.context(o)({type:"Sphere"}),o.fillStyle=n.fill||"black",o.fill()})})}},c.plugins.land=function(n){return function(o){var e=null;o.onInit(function(){var n=o.plugins.topojson.world;e=t.feature(n,n.objects.land)}),o.onDraw(function(){o.withSavedContext(function(t){t.beginPath(),o.path.context(t)(e),0!=n.fill&&(t.fillStyle=n.fill||"white",t.fill()),n.stroke&&(n.lineWidth&&(t.lineWidth=n.lineWidth),t.strokeStyle=n.stroke,t.stroke())})})}},c.plugins.borders=function(n){return function(o){var e=null,i={internal:function(n,t){return n.id!==t.id},external:function(n,t){return n.id===t.id},both:function(){return!0}};o.onInit(function(){var r=o.plugins.topojson.world,l=r.objects.countries,a=n.type||"internal";e=t.mesh(r,l,i[a])}),o.onDraw(function(){o.withSavedContext(function(t){t.beginPath(),o.path.context(t)(e),t.strokeStyle=n.stroke||"gray",n.lineWidth&&(t.lineWidth=n.lineWidth),t.stroke()})})}},c.plugins.earth=function(n){var n=n||{},t=n.topojson||{},o=n.oceans||{},e=n.land||{},i=n.borders||{};return function(n){c.plugins.topojson(t)(n),c.plugins.oceans(o)(n),c.plugins.land(e)(n),c.plugins.borders(i)(n)}},c.plugins.pings=function(t){var o=[],e=function(n,e,i){var i=i||{};i.color=i.color||t.color||"white",i.ttl=i.ttl||t.ttl||2e3,i.angle=i.angle||t.angle||5,o.push({lat:n,lng:e,time:new Date,options:i})},i=function(n,t,e){for(var i=[],l=0;l90&&(i[1]=90),i[1]<-90&&(i[1]=-90),i[0]>=180&&(i[0]-=360),t.projection.rotate(i),l()});n.select(t.canvas).call(o)})}},c}); \ No newline at end of file +!function(n,t){"function"==typeof define&&define.amd?define(["d3","topojson"],t):"object"==typeof exports?module.exports=t(require("d3"),require("topojson")):n.planetaryjs=t(n.d3,n.topojson,n)}(this,function(n,t,o){"use strict";var e=null;o&&(e=o.planetaryjs);var i=[],r=function(t,o,e){n.timer(function(){t.context.clearRect(0,0,o.width,o.height);for(var n=0;n=o.onInit.length?r(n,t,o):i(l)};i(l)}else r(n,t,o)},u=function(n,t,o,e){l(n,o),n.canvas=t,n.context=t.getContext("2d"),a(n,t,e)},c={plugins:{},noConflict:function(){return o.planetaryjs=e,c},loadPlugin:function(n){i.push(n)},planet:function(){var t=[],o={onInit:[],onDraw:[]},e={plugins:{},draw:function(n){u(e,n,t,o)},onInit:function(n){o.onInit.push(n)},onDraw:function(n){o.onDraw.push(n)},loadPlugin:function(n){t.push(n)},withSavedContext:function(n){if(!this.context)throw new Error("No canvas to fetch context for");this.context.save(),n(this.context),this.context.restore()}};return e.projection=n.geo.orthographic().clipAngle(90).precision(0),e.path=n.geo.path().projection(e.projection),e}};return c.plugins.topojson=function(t){return function(o){o.plugins.topojson={},o.onInit(function(e){if(t.world)o.plugins.topojson.world=t.world,setTimeout(e,0);else{var i=t.file||"world-110m.json";n.json(i,function(n,t){if(n)throw new Error("Could not load JSON "+i);o.plugins.topojson.world=t,e()})}})}},c.plugins.oceans=function(n){return function(t){t.onDraw(function(){t.withSavedContext(function(o){o.beginPath(),t.path.context(o)({type:"Sphere"}),o.fillStyle=n.fill||"black",o.fill()})})}},c.plugins.land=function(n){return function(o){var e=null;o.onInit(function(){var n=o.plugins.topojson.world;e=t.feature(n,n.objects.land)}),o.onDraw(function(){o.withSavedContext(function(t){t.beginPath(),o.path.context(t)(e),0!=n.fill&&(t.fillStyle=n.fill||"white",t.fill()),n.stroke&&(n.lineWidth&&(t.lineWidth=n.lineWidth),t.strokeStyle=n.stroke,t.stroke())})})}},c.plugins.borders=function(n){return function(o){var e=null,i={internal:function(n,t){return n.id!==t.id},external:function(n,t){return n.id===t.id},both:function(){return!0}};o.onInit(function(){var r=o.plugins.topojson.world,l=r.objects.countries,a=n.type||"internal";e=t.mesh(r,l,i[a])}),o.onDraw(function(){o.withSavedContext(function(t){t.beginPath(),o.path.context(t)(e),t.strokeStyle=n.stroke||"gray",n.lineWidth&&(t.lineWidth=n.lineWidth),t.stroke()})})}},c.plugins.earth=function(n){var n=n||{},t=n.topojson||{},o=n.oceans||{},e=n.land||{},i=n.borders||{};return function(n){c.plugins.topojson(t)(n),c.plugins.oceans(o)(n),c.plugins.land(e)(n),c.plugins.borders(i)(n)}},c.plugins.pings=function(t){var o=[],t=t||{},e=function(n,e,i){var i=i||{};i.color=i.color||t.color||"white",i.angle=i.angle||t.angle||5,i.ttl=i.ttl||t.ttl||2e3;var r={time:new Date,options:i};t.latitudeFirst?(r.lat=n,r.lng=e):(r.lng=n,r.lat=e),o.push(r)},i=function(n,t,e){for(var i=[],l=0;l90&&(i[1]=90),i[1]<-90&&(i[1]=-90),i[0]>=180&&(i[0]-=360),t.projection.rotate(i),l()});n.select(t.canvas).call(o)})}},c}); \ No newline at end of file diff --git a/site/public/documentation/builtin_pings.md b/site/public/documentation/builtin_pings.md index 361153d..c7654b2 100644 --- a/site/public/documentation/builtin_pings.md +++ b/site/public/documentation/builtin_pings.md @@ -13,6 +13,7 @@ Valid keys for `config` are: * `color`: the default color for pings; defaults to `"white"` * `ttl`: the default TTL for pings in milliseconds (how long they take to fade out); defaults to 2000 * `angle`: the maximum angle for the ping (it will grow to this size over the course of its TTL); defaults to `5` +* `latitudeFirst`: reverse the order of the latitudinal and longitudinal coordinates passed to the `add` function (so that the latitudinal coordinate comes first); defaults to false. See the note on `add`, below, for more information.
JavaScript
@@ -24,9 +25,17 @@ planetaryjs.plugins.pings({ ```
-**`planet.plugins.pings.add(lat, lng, [config])`** +**`planet.plugins.pings.add(lng, lat, [config])`** -Add a new ping to the globe at the latitudinal and longitudinal coordinates specified by `lat` and `lng`. `config` may take all the same keys as the configuration option for the plugin itself; any values will overwrite values from that object, if any were set. +Add a new ping to the globe at the longitudinal and latitudinal coordinates specified by `lng` and `lat`. Valid keys for `config` are: + +* `color`: the default color for pings; defaults to `"white"` +* `ttl`: the default TTL for pings in milliseconds (how long they take to fade out); defaults to 2000 +* `angle`: the maximum angle for the ping (it will grow to this size over the course of its TTL); defaults to `5` + +Any values not set by `config` will default to the values specified in the plugin's configuration, if any were set. + +**Note that the longitudinal coordinate comes first, followed by the latitudinal coordinate, unless you pass `latitudeFirst` as an option to the plugin configuration function.** This corresponds to the conventions used by D3 (which Planetary.js is based on); for more information on the problem of axis ordering in software, see [this article at the GeoTools web site](http://docs.geotools.org/latest/userguide/library/referencing/order.html).
JavaScript
@@ -38,7 +47,7 @@ setInterval(function() { var lng = Math.random() * 360 - 180; var color = colors[Math.floor(Math.random() * colors.length)]; var angle = Math.random() * 10; - planet.plugins.pings.add(lat, lng, { color: color, ttl: 2000, angle: angle }); + planet.plugins.pings.add(lng, lat, { color: color, ttl: 2000, angle: angle }); }, 250); ```
diff --git a/site/public/documentation/faq.md b/site/public/documentation/faq.md index b55bcad..44b036c 100644 --- a/site/public/documentation/faq.md +++ b/site/public/documentation/faq.md @@ -1,6 +1,14 @@ FAQ === +**Q:** Why are the pings I add from the [Pings plugin](/documentation/builtin_pings.html) in the wrong place? + +**A:** Like D3 on which it is based, Planetary.js accepts coordinates with the longitudinal coordinate first. You can set the `latitudeFirst` option in the plugin configuration to change this. There is some additional discussion on the subject in the [Pings plugin documentation](/documentation/builtin_pings.html). + +
+ +
+ **Q:** Why can't I access my DOM element? **A:** Planetary.js provides no methods for DOM access or for waiting for the DOM ready event; you'll need to handle this on your own or use a third-party library. diff --git a/site/public/examples/quake.ejs b/site/public/examples/quake.ejs index 48fed08..a98ea89 100644 --- a/site/public/examples/quake.ejs +++ b/site/public/examples/quake.ejs @@ -155,7 +155,7 @@ for (var i = 0; i < toPing.length; i++) { var ping = toPing[i]; - planet.plugins.pings.add(ping.lat, ping.lng, { + planet.plugins.pings.add(ping.lng, ping.lat, { // Here we use the `angles` and `colors` scales we built earlier // to convert magnitudes to appropriate angles and colors. angle: angles(ping.mag), diff --git a/site/public/examples/quake/quake.js b/site/public/examples/quake/quake.js index f4296d0..c6fb4f9 100644 --- a/site/public/examples/quake/quake.js +++ b/site/public/examples/quake/quake.js @@ -132,7 +132,7 @@ for (var i = 0; i < toPing.length; i++) { var ping = toPing[i]; - planet.plugins.pings.add(ping.lat, ping.lng, { + planet.plugins.pings.add(ping.lng, ping.lat, { // Here we use the `angles` and `colors` scales we built earlier // to convert magnitudes to appropriate angles and colors. angle: angles(ping.mag), diff --git a/site/public/examples/rotating.ejs b/site/public/examples/rotating.ejs index 526833c..555c563 100644 --- a/site/public/examples/rotating.ejs +++ b/site/public/examples/rotating.ejs @@ -53,7 +53,7 @@ var lat = Math.random() * 170 - 85; var lng = Math.random() * 360 - 180; var color = colors[Math.floor(Math.random() * colors.length)]; - globe.plugins.pings.add(lat, lng, { color: color, ttl: 2000, angle: Math.random() * 10 }); + globe.plugins.pings.add(lng, lat, { color: color, ttl: 2000, angle: Math.random() * 10 }); }, 250); var canvas = document.getElementById('rotatingGlobe'); diff --git a/site/public/examples/rotating.js b/site/public/examples/rotating.js index bc89d8b..ecab566 100644 --- a/site/public/examples/rotating.js +++ b/site/public/examples/rotating.js @@ -36,7 +36,7 @@ var lat = Math.random() * 170 - 85; var lng = Math.random() * 360 - 180; var color = colors[Math.floor(Math.random() * colors.length)]; - globe.plugins.pings.add(lat, lng, { color: color, ttl: 2000, angle: Math.random() * 10 }); + globe.plugins.pings.add(lng, lat, { color: color, ttl: 2000, angle: Math.random() * 10 }); }, 250); var canvas = document.getElementById('rotatingGlobe'); diff --git a/site/public/js/homepage.js b/site/public/js/homepage.js index 159a112..b05b3d7 100644 --- a/site/public/js/homepage.js +++ b/site/public/js/homepage.js @@ -36,7 +36,7 @@ var lat = Math.random() * 170 - 85; var lng = Math.random() * 360 - 180; var color = colors[Math.floor(Math.random() * colors.length)]; - globe.plugins.pings.add(lat, lng, { color: color, ttl: 2000, angle: Math.random() * 10 }); + globe.plugins.pings.add(lng, lat, { color: color, ttl: 2000, angle: Math.random() * 10 }); }, 250); var canvas = document.getElementById('homepage-globe-canvas'); diff --git a/site/public/js/lib/planetaryjs.min.js b/site/public/js/lib/planetaryjs.min.js index 541df69..e8636c4 100644 --- a/site/public/js/lib/planetaryjs.min.js +++ b/site/public/js/lib/planetaryjs.min.js @@ -1,2 +1,2 @@ /*! Planetary.js 0.2.2 | (c) 2013 Brandon Tilley | Released under MIT License */ -!function(n,t){"function"==typeof define&&define.amd?define(["d3","topojson"],t):"object"==typeof exports?module.exports=t(require("d3"),require("topojson")):n.planetaryjs=t(n.d3,n.topojson,n)}(this,function(n,t,o){"use strict";var e=null;o&&(e=o.planetaryjs);var i=[],r=function(t,o,e){n.timer(function(){t.context.clearRect(0,0,o.width,o.height);for(var n=0;n=o.onInit.length?r(n,t,o):i(l)};i(l)}else r(n,t,o)},u=function(n,t,o,e){l(n,o),n.canvas=t,n.context=t.getContext("2d"),a(n,t,e)},c={plugins:{},noConflict:function(){return o.planetaryjs=e,c},loadPlugin:function(n){i.push(n)},planet:function(){var t=[],o={onInit:[],onDraw:[]},e={plugins:{},draw:function(n){u(e,n,t,o)},onInit:function(n){o.onInit.push(n)},onDraw:function(n){o.onDraw.push(n)},loadPlugin:function(n){t.push(n)},withSavedContext:function(n){if(!this.context)throw new Error("No canvas to fetch context for");this.context.save(),n(this.context),this.context.restore()}};return e.projection=n.geo.orthographic().clipAngle(90).precision(0),e.path=n.geo.path().projection(e.projection),e}};return c.plugins.topojson=function(t){return function(o){o.plugins.topojson={},o.onInit(function(e){if(t.world)o.plugins.topojson.world=t.world,setTimeout(e,0);else{var i=t.file||"world-110m.json";n.json(i,function(n,t){if(n)throw new Error("Could not load JSON "+i);o.plugins.topojson.world=t,e()})}})}},c.plugins.oceans=function(n){return function(t){t.onDraw(function(){t.withSavedContext(function(o){o.beginPath(),t.path.context(o)({type:"Sphere"}),o.fillStyle=n.fill||"black",o.fill()})})}},c.plugins.land=function(n){return function(o){var e=null;o.onInit(function(){var n=o.plugins.topojson.world;e=t.feature(n,n.objects.land)}),o.onDraw(function(){o.withSavedContext(function(t){t.beginPath(),o.path.context(t)(e),0!=n.fill&&(t.fillStyle=n.fill||"white",t.fill()),n.stroke&&(n.lineWidth&&(t.lineWidth=n.lineWidth),t.strokeStyle=n.stroke,t.stroke())})})}},c.plugins.borders=function(n){return function(o){var e=null,i={internal:function(n,t){return n.id!==t.id},external:function(n,t){return n.id===t.id},both:function(){return!0}};o.onInit(function(){var r=o.plugins.topojson.world,l=r.objects.countries,a=n.type||"internal";e=t.mesh(r,l,i[a])}),o.onDraw(function(){o.withSavedContext(function(t){t.beginPath(),o.path.context(t)(e),t.strokeStyle=n.stroke||"gray",n.lineWidth&&(t.lineWidth=n.lineWidth),t.stroke()})})}},c.plugins.earth=function(n){var n=n||{},t=n.topojson||{},o=n.oceans||{},e=n.land||{},i=n.borders||{};return function(n){c.plugins.topojson(t)(n),c.plugins.oceans(o)(n),c.plugins.land(e)(n),c.plugins.borders(i)(n)}},c.plugins.pings=function(t){var o=[],e=function(n,e,i){var i=i||{};i.color=i.color||t.color||"white",i.ttl=i.ttl||t.ttl||2e3,i.angle=i.angle||t.angle||5,o.push({lat:n,lng:e,time:new Date,options:i})},i=function(n,t,e){for(var i=[],l=0;l90&&(i[1]=90),i[1]<-90&&(i[1]=-90),i[0]>=180&&(i[0]-=360),t.projection.rotate(i),l()});n.select(t.canvas).call(o)})}},c}); \ No newline at end of file +!function(n,t){"function"==typeof define&&define.amd?define(["d3","topojson"],t):"object"==typeof exports?module.exports=t(require("d3"),require("topojson")):n.planetaryjs=t(n.d3,n.topojson,n)}(this,function(n,t,o){"use strict";var e=null;o&&(e=o.planetaryjs);var i=[],r=function(t,o,e){n.timer(function(){t.context.clearRect(0,0,o.width,o.height);for(var n=0;n=o.onInit.length?r(n,t,o):i(l)};i(l)}else r(n,t,o)},u=function(n,t,o,e){l(n,o),n.canvas=t,n.context=t.getContext("2d"),a(n,t,e)},c={plugins:{},noConflict:function(){return o.planetaryjs=e,c},loadPlugin:function(n){i.push(n)},planet:function(){var t=[],o={onInit:[],onDraw:[]},e={plugins:{},draw:function(n){u(e,n,t,o)},onInit:function(n){o.onInit.push(n)},onDraw:function(n){o.onDraw.push(n)},loadPlugin:function(n){t.push(n)},withSavedContext:function(n){if(!this.context)throw new Error("No canvas to fetch context for");this.context.save(),n(this.context),this.context.restore()}};return e.projection=n.geo.orthographic().clipAngle(90).precision(0),e.path=n.geo.path().projection(e.projection),e}};return c.plugins.topojson=function(t){return function(o){o.plugins.topojson={},o.onInit(function(e){if(t.world)o.plugins.topojson.world=t.world,setTimeout(e,0);else{var i=t.file||"world-110m.json";n.json(i,function(n,t){if(n)throw new Error("Could not load JSON "+i);o.plugins.topojson.world=t,e()})}})}},c.plugins.oceans=function(n){return function(t){t.onDraw(function(){t.withSavedContext(function(o){o.beginPath(),t.path.context(o)({type:"Sphere"}),o.fillStyle=n.fill||"black",o.fill()})})}},c.plugins.land=function(n){return function(o){var e=null;o.onInit(function(){var n=o.plugins.topojson.world;e=t.feature(n,n.objects.land)}),o.onDraw(function(){o.withSavedContext(function(t){t.beginPath(),o.path.context(t)(e),0!=n.fill&&(t.fillStyle=n.fill||"white",t.fill()),n.stroke&&(n.lineWidth&&(t.lineWidth=n.lineWidth),t.strokeStyle=n.stroke,t.stroke())})})}},c.plugins.borders=function(n){return function(o){var e=null,i={internal:function(n,t){return n.id!==t.id},external:function(n,t){return n.id===t.id},both:function(){return!0}};o.onInit(function(){var r=o.plugins.topojson.world,l=r.objects.countries,a=n.type||"internal";e=t.mesh(r,l,i[a])}),o.onDraw(function(){o.withSavedContext(function(t){t.beginPath(),o.path.context(t)(e),t.strokeStyle=n.stroke||"gray",n.lineWidth&&(t.lineWidth=n.lineWidth),t.stroke()})})}},c.plugins.earth=function(n){var n=n||{},t=n.topojson||{},o=n.oceans||{},e=n.land||{},i=n.borders||{};return function(n){c.plugins.topojson(t)(n),c.plugins.oceans(o)(n),c.plugins.land(e)(n),c.plugins.borders(i)(n)}},c.plugins.pings=function(t){var o=[],t=t||{},e=function(n,e,i){var i=i||{};i.color=i.color||t.color||"white",i.angle=i.angle||t.angle||5,i.ttl=i.ttl||t.ttl||2e3;var r={time:new Date,options:i};t.latitudeFirst?(r.lat=n,r.lng=e):(r.lng=n,r.lat=e),o.push(r)},i=function(n,t,e){for(var i=[],l=0;l90&&(i[1]=90),i[1]<-90&&(i[1]=-90),i[0]>=180&&(i[0]-=360),t.projection.rotate(i),l()});n.select(t.canvas).call(o)})}},c}); \ No newline at end of file diff --git a/src/plugins.js b/src/plugins.js index 08ea2d9..6933827 100644 --- a/src/plugins.js +++ b/src/plugins.js @@ -114,13 +114,22 @@ planetaryjs.plugins.pings = function(config) { var pings = []; + var config = config || {}; - var addPing = function(lat, lng, options) { + var addPing = function(lng, lat, options) { var options = options || {}; options.color = options.color || config.color || 'white'; - options.ttl = options.ttl || config.ttl || 2000; options.angle = options.angle || config.angle || 5; - pings.push({ lat: lat, lng: lng, time: new Date(), options: options }); + options.ttl = options.ttl || config.ttl || 2000; + var ping = { time: new Date(), options: options }; + if (config.latitudeFirst) { + ping.lat = lng; + ping.lng = lat; + } else { + ping.lng = lng; + ping.lat = lat; + } + pings.push(ping); }; var drawPings = function(planet, context, now) {