planetary.js/documentation/builtin_pings.html
Brandon Tilley 5cad239577 Update site
2013-12-23 14:16:19 -08:00

124 lines
5.4 KiB
HTML

<!doctype html>
<html>
<head>
<title>Planetary.js: Awesome interactive globes for the web</title>
<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:400,700|Open+Sans:300italic,400,300,700' rel='stylesheet' type='text/css'>
<link type="text/css" rel="stylesheet" href="/semantic/css/semantic.min.css">
<link type="text/css" rel="stylesheet" href="/css/planetaryjs.css">
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<link href="/css/prism.css" rel="stylesheet">
</head>
<body>
<div class='ui fixed inverted large menu main-menu'>
<div class='items'>
<a class='item title' href='/index.html'>
<i class='globe icon'></i>Planetary.js
</a>
<span class='spacer hide-on-mobile'></span>
<a class='item minor' href='https://github.com/BinaryMuse/planetary.js/releases'>
<i class='download icon'></i><span class='hide-on-mobile'>Download</span>
</a>
<a class='item minor ' href='/examples/'>
<i class='laptop icon'></i><span class='hide-on-mobile'>Examples</span>
</a>
<a class='item minor active' href='/documentation/'>
<i class='book icon'></i><span class='hide-on-mobile'>Documentation</span>
</a>
<a class='item minor' href='https://github.com/BinaryMuse/planetary.js'>
<i class='github alternate icon'></i><span class='hide-on-mobile'>Fork on GitHub</span>
</a>
</div>
</div>
<div class='content container'>
<div class='page ui slim stackable grid'>
<div class='four wide column'>
<div class='ui fluid vertical menu'>
<a class='red item ' href='/documentation/index.html'>
Introduction
<i class='icon home'></i>
</a>
<a class='blue item ' href='/documentation/core.html'>
Core API
<i class='icon setting'></i>
</a>
<a class='orange item ' href='/documentation/planet.html'>
Planet API
<i class='icon globe'></i>
</a>
<a class='teal item ' href='/documentation/plugins.html'>
Plugins
<i class='icon edit'></i>
</a>
<a class='purple item with-subitems ' href='/documentation/builtin.html'>
Built-In Plugins
<i class='icon bolt'></i>
</a>
<div class='item contains-subitems'>
<div class='menu'>
<a class='item ' href='/documentation/builtin_earth.html'>Earth</a>
<a class='item ' href='/documentation/builtin_topojson.html'>TopoJSON</a>
<a class='item ' href='/documentation/builtin_oceans.html'>Oceans</a>
<a class='item ' href='/documentation/builtin_land.html'>Land</a>
<a class='item ' href='/documentation/builtin_borders.html'>Borders</a>
<a class='item active' href='/documentation/builtin_pings.html'>Pings</a>
<a class='item ' href='/documentation/builtin_zoom.html'>Zoom</a>
<a class='item ' href='/documentation/builtin_drag.html'>Drag</a>
</div>
</div>
<a class='red item ' href='/documentation/faq.html'>
FAQ
<i class='icon help'></i>
</a>
<a class='green item ' href='/documentation/help.html'>
Getting Help
<i class='icon phone'></i>
</a>
</div>
</div>
<div class='twelve wide column'>
<h1>Pings Plugin</h1>
<p>The <code>pings</code> plugin allows you to display animated &quot;pings&quot; at any location on the planet. It publishes a method to create pings at <code>planet.plugins.pings.add</code>.</p>
<h2>API</h2>
<p><strong><code>planetaryjs.plugins.pings([config])</code></strong></p>
<p>Valid keys for <code>config</code> are:</p>
<ul>
<li><code>color</code>: the default color for pings; defaults to <code>&quot;white&quot;</code></li>
<li><code>ttl</code>: the default TTL for pings in milliseconds (how long they take to fade out); defaults to 2000</li>
<li><code>angle</code>: the maximum angle for the ping (it will grow to this size over the course of its TTL); defaults to <code>5</code></li>
</ul>
<div class='ui raise segment'>
<div class='ui red ribbon label'>JavaScript</div>
<pre><code class="language-javascript">planetaryjs.plugins.pings({
color: &#39;yellow&#39;, ttl: 5000, angle: 10
});</code></pre>
<p></div></p>
<p><strong><code>planet.plugins.pings.add(lat, lng, [config])</code></strong></p>
<p>Add a new ping to the globe at the latitudinal and longitudinal coordinates specified by <code>lat</code> and <code>lng</code>. <code>config</code> 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.</p>
<div class='ui raise segment'>
<div class='ui red ribbon label'>JavaScript</div>
<pre><code class="language-javascript">var colors = [&#39;red&#39;, &#39;yellow&#39;, &#39;white&#39;, &#39;orange&#39;, &#39;green&#39;, &#39;cyan&#39;, &#39;pink&#39;];
setInterval(function() {
var lat = Math.random() * 170 - 85;
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 });
}, 250);</code></pre>
<p></div></p>
</div>
</div>
</div>
<script type='text/javascript' src='/js/prism.js'></script>
</body>
</html>