ラベル animation の投稿を表示しています。 すべての投稿を表示
ラベル animation の投稿を表示しています。 すべての投稿を表示

2015年12月31日木曜日

2 - ol3.12ex 145b - Flight Animation 2

「flight-animation.js(2145-ol3ex.js)」は、マップを表示するための JavaScript ファイルです。


arc.js は、

GitHub springmeyer/arc.js
https://github.com/springmeyer/arc.js/

の README.md に次のようにあります。

Calculate great circles routes as lines in GeoJSON or WKT format.
Algorithms from http://williams.best.vwh.net/avform.htm#Intermediate
Includes basic support for splitting lines that cross the dateline, based on a partial port of code from OGR.

GeoJSONまたはWKT形式のラインのような大円ルートを計算します。
http://williams.best.vwh.net/avform.htm#Intermediate からのアルゴリズムです。
OGR からのコードの一部のポートに基づいて、日付変更線を横断する分割ラインの基本的なサポートが含んでいます。


「2145-ol3ex.js」
var map = new ol.Map({
 layers: [
  new ol.layer.Tile({
  /** ol.layer.Tile 
   * For layer sources that provide pre-rendered, tiled 
   * images in grids that are organized by zoom levels 
   * for specific resolutions. 
   * プリレンダリング(事前描画)を提供するレイヤソースのため
   * の、特定の解像度でのズームレベルによって編成されているグ
   * リッドのタイルイメージ。(ol3 API)
   */
   source: new ol.source.Stamen({
   /** ol.source.Stamen
    * Layer source for the Stamen tile server.
    * Stamen タイルサーバのレイヤソース。(ol3 API)
    * (2 - ol3ex 24b - Stamen example 1 参照)
    */
    layer: 'toner'
   })
  })
 ],
 target: 'map',
 view: new ol.View({
  center: [0, 0],
  zoom: 2
 })
});
var defaultStroke = new ol.style.Stroke({
/** ol.style.Stroke 
 * Set stroke style for vector features. 
 * Note that the defaults given are the Canvas defaults, 
 * which will be used if option is not defined. 
 * The get functions return whatever was entered in 
 * the options;  they will not return the default.
 * ベクタフィーチャのためのストロークスタイルの設定。
 * デフォルトは、オプションが定義されていない場合に使用され
 * る Canvas のデフォルトを与えられることに注意してください。
 * GET 関数は、オプションで入力されたものはすべて返します。
 * それらはデフォルトを返しません。
 * (ol3 API[説明は Stable Only のチェックを外すと表示])
 */
 color: '#EAE911',
 /** color:
  * Color. See ol.color for possible formats. Default 
  * null; if null, the Canvas/renderer default black 
  * will be used.
  * 色。可能なフォーマットについては ol.color を参照してく
  * ださい。デフォルトはnull; nullの場合、Canvas/renderer 
  * デフォルトの黒が使用されます。
  * (ol3 API[説明は Stable Only のチェックを外すと表示])
  */
 width: 2
});
var defaultStyle = new ol.style.Style({
/** ol.style.Style 
 * Container for vector feature rendering styles. Any 
 * changes made to the style or its children through 
 * set*() methods will not take effect until the 
 * feature or layer that uses the style is re-rendered.
 * ベクタフィーチャがスタイルを描画するためのコンテナ。
 * スタイルや set*() メソッドを通じてその子に加えられた変
 * 更は、スタイルを使用するフィーチャまたはレイヤが再レン
 * ダリングされるまで有効になりません。
 * (ol3 API[説明は Stable Only のチェックを外すと表示])
 */
 stroke: defaultStroke
});
var pointsPerMs = 0.1;
var animateFlights = function(event) {
 var vectorContext = event.vectorContext;
 /** vectorContext{ol.render.VectorContext} 
  * For canvas, this is an instance of 
  * ol.render.canvas.Immediate.
  * キャンバスの場合、これは  ol.render.canvas.Immediate 
  * のインスタンスです。
  * (ol3 API[説明は Stable Only のチェックを外すと表示])
  */
 var frameState = event.frameState;
 /** frameState{olx.FrameState}
  * An object representing the current render frame 
  * state.
  * 現在の描画フレーム状態を表すオブジェクト。
  * (ol3 API[説明は Stable Only のチェックを外すと表示])
  */
 vectorContext.setFillStrokeStyle(null, defaultStroke);
 /** setFillStrokeStyle(fillStyle, strokeStyle) 
  * Set the fill and stroke style for subsequent draw 
  * operations. To clear either fill or stroke styles, 
  * pass null for the appropriate parameter.
  * ドロー操作後のための塗つぶしと線のスタイルを設定します。 
  * 塗りつぶしまたは線スタイルのいずれかをクリアするために、
  * 適切なパラメータに null を渡します。
  * (ol3 API[説明は Stable Only のチェックを外すと表示])
  */
 var features = flightsSource.getFeatures();
 /** getFeatures()
  * Get all features on the source.
  * ソース上の不すべてのフィーチャを取得します。
  * (ol3 API)
  */
 for (var i = 0; i < features.length; i++) {
  var feature = features[i];
  if (!feature.get('finished')) {
  /** get(key)
   * Gets a value.(ol3 API)
   */
   // only draw the lines for which the animation has 
   // not finished yet
   // アニメーションがまだ完了していない線だけを引きます。
   var coords = feature.getGeometry().getCoordinates();
   /** getGeometry()
    * Get the feature's default geometry. A feature may 
    * have any number of named geometries. The "default" 
    * geometry (the one that is rendered by default) is 
    * set when calling ol.Feature#setGeometry.
    * フィーチャのデフォルトのジオメトリを取得します。フィー
    * チャは、任意の数の指定のジオメトリのを有することができ 
    * ます。「デフォルト」のジオメトリ(デフォルトでレンダリ
    * ングされるもの)が ol.Feature#setGeometry を呼び出すと
    * きに設定されています。(ol3 API)
    */
   /** getCoordinates()
    * Return the coordinates of the linestring.
    * ラインストリングの座標を返します。(ol3 API)
    */
   var elapsedTime = frameState.time - feature.get('start');
   var elapsedPoints = elapsedTime * pointsPerMs;
   if (elapsedPoints >= coords.length) {
    feature.set('finished', true);
    /** set(key, value, opt_silent)
     * Sets a value.(ol3 API)
     */
   }
   var maxIndex = Math.min(elapsedPoints, coords.length);
   /** Math.min() 
    * 引数として与えた複数の数の中で最小の数を返します。
    * (MDN[https://developer.mozilla.org/ja/docs/Web/
    * JavaScript/Reference/Global_Objects/Math/min])
    */
   var currentLine = new ol.geom.LineString(coords.slice(0, maxIndex));
   /** ol.geom.LineString
    * Linestring geometry.(ol3 API)
    */
   // directly draw the line with the vector context
   // ベクトルコンテキストで,、直接、線を引きます。
   vectorContext.drawLineStringGeometry(currentLine, feature);
   /** drawLineStringGeometry(lineStringGeometry)
    * Render a LineString into the canvas. Rendering is 
    * immediate and uses the current style.
    * キャンバス(canvas)にラインストリング(LineString)
    * をレンダリングします。レンダリングは即時であり、現在の
    * スタイルを使用します。
    * (ol3 API[説明は Stable Only のチェックを外すと表示])
    */
  }
 }
 // tell OL3 to continue the postcompose animation
 // OL3 に postcompose アニメーションを継続することを教えます。
 map.render();
 /** render()
  * Request a map rendering (at the next animation 
  * frame).
  * (次のアニメーションフレームで)map 描画を要求します。
  * (ol3 API)
  */
};
var addLater = function(feature, timeout) {
 window.setTimeout(function() {
 /** setTimeout(func, dylay)
  * 指定された遅延の後に、コードの断片または関数を実行します。
  * func : delay ミリ秒後に実行したい関数。
  * delay : 関数呼び出しを遅延させるミリ秒(1/1000 秒)。
  * (MDN[https://developer.mozilla.org/ja/docs/Web/
  * API/Window/setTimeout])
  */
  feature.set('start', new Date().getTime());
  /** Date
   * 日付や時刻を扱うことが可能な、JavaScript の Date 
   * インスタンスを生成します。
   * (MDN[https://developer.mozilla.org/ja/docs/Web/
   * JavaScript/Reference/Global_Objects/Date])
   */
  /** Date.prototype.getTime()
   * ユニバーサル時間に従い、指定された日付の時刻に対応する数
   * 値を返します。
   * GetTime メソッドによって返される値は、1970 年 1 月 1 日 
   * 00:00:00 UTC からの経過ミリ秒です。このメソッドは、日付
   * と時刻を別の Date オブジェクトに割り当てるために使用でき
   * ます。
   * (MDN[https://developer.mozilla.org/ja/docs/Web/
   * JavaScript/Reference/Global_Objects/Date/getTime])
   */
  flightsSource.addFeature(feature);
  /** addFeature(feature)
   * Add a single feature to the source. If you want to 
   * add batch of features at once, call 
   * source.addFeatures() a instead.
   * 単一フィーチャをソースに追加します。一度にフィーチャの
   * バッチを追加したいときは、替りに source.addFeatures() 
   * を呼び出します。(ol3 API)
   */
 }, timeout);
};
var flightsSource = new ol.source.Vector({
/** ol.source.Vector
 * Provides a source of features for vector layers. 
 * Vector features provided by this source are suitable 
 * for editing. See ol.source.VectorTile for vector 
 * data that is optimized for rendering.
 * ベクタレイヤのフィーチャのソースを用意します。このソー
 * スが提供するベクタフィーチャは、編集に適しています。レ
 * ンダリングのために最適化されたベクタデータの 
 * ol.source.VectorTile を参照してください。(ol3 API)
 */
 wrapX: false,
 /** wrapX:
  * Wrap the world horizontally. Default is true. For 
  * vector editing across the -180° and 180° meridians 
  * to work properly, this should be set to false. The 
  * resulting geometry coordinates will then exceed the 
  * world bounds.
  * 水平方向に世界をラップします。デフォルトは true。-180°
  * と180°の子午線を横切って編集するベクトルが正しく動作す
  * るために、これは false に設定する必要があります。ジオメ
  * トリの座標の結果は、その後、世界の境界線を超えます。
  * (ol3 API[説明は Stable Only のチェックを外すと表示])
  */
 attributions: [new ol.Attribution({
 /** ol.Attribution
  * An attribution for a layer source.
  * レイヤソースの属性(ol3 API)
  */
  html: 'Flight data by ' +
   '<a href="http://openflights.org/data.html">OpenFlights</a>,'
 })],
 loader: function(extent, resolution, projection) {
  /** loader:
   * The loader function used to load features, from a 
   * remote source for example. Note that the source 
   * will create and use an XHR feature loader when 
   * url is set.
   * 例えばリモートソースから、フィーチャをロードするために
   * 使用される loader 関数。ソースは、url が設定されている
   * 場合、XHR feature loader を作成し使用することに注意し
   * てください。
   * (ol3 API[説明は Stable Only のチェックを外すと表示])
   */
   // var url = 'data/openflights/flights.json';
   var url = 'v3.12.1/examples/data/openflights/flights.json';
   fetch(url).then(function(response) {
   /** Fetch API(現在、Chrome, Firefox, Opera のみサポート)
    * The Fetch API provides an interface for fetching 
    * resources (e.g., across the network.) It will 
    * seem familiar to anyone who has used 
    * XMLHttpRequest, but the new API provides a more 
    * powerful and flexible feature set.
    * Fetch API は、(例えば、ネットワークを介して)のリソー
    * スを取得するためのインタフェースを提供します。これは、
    * XMLHttpRequest を使用している人にはおなじみだと思われ
    * ますが、新しい API がより強力で柔軟な機能セットを提供
    * します。
    * (MDN[https://developer.mozilla.org/en-US/docs/Web/
    * API/Fetch_API])
    * Response
    * The Response interface of the Fetch API represents 
    * the response to a request.
    * Fetch API の Response インターフェイスは、要求(request)
    * に対する応答(response)を表します。
    * (MDN[https://developer.mozilla.org/en-US/docs/Web/
    * API/Response])
    * Body.json()
    * The json() method of the Body mixin takes a 
    * Response stream and reads it to completion. It 
    * returns a promise that resolves with an object 
    * literal containing the JSON data.
    * Body mixin  の json() メソッドは、Response stream を
    * 受け取り、完了にそれを読み込みます。これは、JSON データ
    * を含むオブジェクトリテラルで解決するpromise を返します。
    * (MDN[https://developer.mozilla.org/en-US/docs/Web/
    * API/Body/json])
    */
    return response.json();
   }).then(function(json) {
    var flightsData = json.flights;
    for (var i = 0; i < flightsData.length; i++) {
     var flight = flightsData[i];
     var from = flight[0];
     var to = flight[1];
     // create an arc circle between the two locations
     // 2地点間のアーク円を作成します。
     var arcGenerator = new arc.GreatCircle(
     /** arc.GreatCircle()
      * Pass the start/end to the GreatCircle 
      * constructor, along with an optional object 
      * representing the properties for this future line.
      * future line のプロパティを表すオプションのオブジェク
      * トと一緒に、GrateCircle コンストラクタに開始/終了
      * (start/end)を渡します。
      * (arc.js API)
      */
      {x: from[1], y: from[0]},
      {x: to[1], y: to[0]});
     var arcLine = arcGenerator.Arc(100, {offset: 10});
     /** Arc()
      * Call the Arc function on the GreatCircle object 
      * to generate a line.
      * ラインを生成するために、GrateCircle オブジェクトの 
      * Arc 関数を呼び出します。
      * (arc.js API)
      */
     if (arcLine.geometries.length === 1) {
      var line = new ol.geom.LineString(arcLine.geometries[0].coords);
      line.transform(ol.proj.get('EPSG:4326'), ol.proj.get('EPSG:3857'));
      /** transform(source, destination)
       * Transform each coordinate of the geometry from 
       * one coordinate reference system to another. The 
       * geometry is modified in place. For example, a 
       * line will be transformed to a line and a circle 
       * to a circle. If you do not want the geometry 
       * modified in place, first clone() it and then use 
       * this function on the clone.
       * ある座標参照系から別のものへジオメトリの各座標を変換
       * します。ジオメトリは、所定の位置に修正されます。例え
       * ば、線は線へ円は円へ変換されます。ジオメトリを所定の
       * 位置に変更したくない場合は、最初にそれを clone() し
       * て、それから clone に関してこの関数を使用します。
       * (ol3 API)
       */
      /** ol.proj.getTransform(source, destination)
       * Given the projection-like objects, searches for 
       * a transformation function to convert a 
       * coordinates array from the source projection to 
       * the destination projection.
       * projection 系オブジェクトを与えられると、変換関数の
       * ための検索は、ソース投影から宛先の投影にの座標の配列
       * に変換します。(ol3 API)
       */
      var feature = new ol.Feature({
      /** ol.Feature
       * A vector object for geographic features with a 
       * geometry and other attribute properties, similar 
       * to the features in vector file formats like 
       * GeoJSON.
       * GeoJSONのようなベクトルファイル形式のフィーチャに類
       * 似した、ジオメトリとその他の属性プロパティを持つ地物
       * フィーチャのためのベクトルオブジェクト。(ol3 API)
       */
       geometry: line,
       finished: false
      });
      // add the feature with a delay so that the 
      // animation for all features does not start at 
      // the same time
      // すべてのフィーチャに対するアニメーションが同時に起動
      // しないように、遅延してフィーチャを追加。
      addLater(feature, i * 50);
     }
    }
    map.on('postcompose', animateFlights);
    /** on(type, listener, opt_this)
     * Listen for a certain type of event.
     * あるタイプのイベントをリッスンします。(ol3 API)
     */
   });
  }
});
var flightsLayer = new ol.layer.Vector({
/** ol.layer.Vector
 * Vector data that is rendered client-side.
 * クライアント側で描画されたベクタデータ。(ol3 API)
 */
 source: flightsSource,
 style: function(feature, resolution) {
 /** style:
  * Layer style. See ol.style for default style which 
  * will be used if this is not defined.
  * レイヤースタイル。これが定義されていない場合に使用される
  * デフォルトのスタイルに対する ol.style を参照してくださ
  * い。(ol3 API)
  */
 // if the animation is still active for a feature, do 
 // not render the feature with the layer style
 // アニメーションがフィーチャに対してまだアクティブである場
 // 合は、レイヤスタイルでフィーチャをレンダリングしません。
  if (feature.get('finished')) {
   return defaultStyle;
  } else {
   return null;
  }
 }
});
map.addLayer(flightsLayer);
/** addLayer(layer)
 * Adds the given layer to the top of this map.
 * 与えられたレイヤをこのマップの一番上に追加します。(ol3 API)
 */


2 - ol3.12ex 145a - Flight Animation 1

「Flight Animation (flight-animation.html)」を参考に地図を表示してみます。
説明に次のようにあります。

This example shows how to use postcompose and vectorContext to animate flights. A great circle arc between two airports is calculated using arc.js and then the flight paths are animated with postcompose. The flight data is provided by OpenFlights (a simplified data set from the Mapbox.js documentation is used).

この例では、フライトをアニメーション化するpostcomposeとvectorContextを使用する方法を示します。 2つの空港間の大円の弧はarc.jsを使用して計算され、その後、飛行経路はpostcomposeでアニメーション化されています。フライトデータをOpenFlightsによって提供されます(Mapbox.jsドキュメントから設定簡略化されたデータが使用されます)。


HTML ファイルの作成
a Eclipse のメニューの「ファイル」->「ファイルを開く」をクリックします。





b 「ファイルを開く」ウィンドウで、「user」->「mapsite」->「ol3proj」->「v3.12.1」->「examples」->「flight-animation.html」をクリックして選択し、「OK」ボタンをクリックします。
同じように「flight-animation.js」を開きます。





c メニューの「ファイル」->「新規」 -> 「ファイル」をクリックします。




d 「ファイル」ウィンドウで「ol3proj」をクリックして選択し、「ファイル名」を「2145-ol3ex.html」と入力し、「次へ」ボタンをクリックします。








e 「File Template」ウィンドウで「HTML 5 Template」をクリックして選択し、「OK」ボタンをクリックします。











f 「flight-animation.html」の内容をコピーして「2145-ol3ex.html」に貼り付け、修正します。
g 同じように、新規に「2145-ol3ex.js」ファイルを作成し、「File Template」ウィンドウで「JavaScript Template」をクリックして選択し、「完了」ボタンをクリックして、「flight-animation.js」の内容をコピーして貼り付け、修正します。「flight-animation-require.js」も「2145-ol3ex-require.js」に貼り付けます。

「21445ol3ex.html」
<!doctype html>
<html lang="en">
 <head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="chrome=1">
  <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" type="text/css">
  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-combined.min.css" type="text/css">
  <!--
  <link rel="stylesheet" href="../css/ol.css" type="text/css">
  <link rel="stylesheet" href="./resources/layout.css" type="text/css">

  <link rel="stylesheet" href="./resources/prism/prism.css" type="text/css">
  <script src="./resources/zeroclipboard/ZeroClipboard.min.js"></script>

  「resources」の位置が変わりました。
  -->
  <!-- ディレクトリ修正 -->
  <link rel="stylesheet" href="v3.12.1/css/ol.css" type="text/css">
  <link rel="stylesheet" href="v3.12.1/examples/resources/layout.css" type="text/css">

  <link rel="stylesheet" href="v3.12.1/examples/resources/prism/prism.css" type="text/css">
  <script src="v3.12.1/examples/resources/zeroclipboard/ZeroClipboard.min.js"></script>
  <script src="https://api.mapbox.com/mapbox.js/plugins/arc.js/v0.1.0/arc.js"></script>
  <script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=fetch"></script>
  <title>Flight Animation</title>
 </head>
 <body>
  <!-- 
  bootstrap-combined.min.css, ol.css, layout.css,
  CSSファイルで設定されたセレクタを使用。
  -->
  <header class="navbar" role="navigation">
   <div class="container" id="navbar-inner-container">
    <!--
    <a class="navbar-brand" href="./"><img src="./resources/logo-70x70.png"> OpenLayers 3 Examples</a>
    -->
    <!-- ディレクトリ修正 -->
    <a class="navbar-brand" href="v3.12.1/examples/"><img src="v3.12.1/examples/resources/logo-70x70.png"> OpenLayers 3 Examples</a>
   </div>
  </header>
  <div class="container-fluid">
   <div class="row-fluid">
    <div class="span12">
     <h4 id="title">Flight Animation</h4>
     <div id="map" class="map"></div>
    </div>
   </div>
   <div class="row-fluid">
    <div class="span12">
     <p id="shortdesc">Demonstrates how to animate flights 
      with ´postcompose´.</p>
     <div id="docs"><p>This example shows how to use 
     <b>postcompose</b> and <b>vectorContext</b> to animate 
     flights. A great circle arc between two airports is 
     calculated using 
     <a href="https://github.com/springmeyer/arc.js">arc.js</a> 
     and then the flight paths are animated with 
     <b>postcompose</b>. The flight data is provided by 
     <a href="http://openflights.org/data.html">OpenFlights</a> 
     (a simplified data set from the 
     <a href="https://www.mapbox.com/mapbox.js/example/v1.0.0/
     animating-flight-paths/"> Mapbox.js documentation</a> 
     is used).</p>
     </div>
     <div id="api-links">Related API documentation: 
      <ul class="inline">
       <li>
        <!-- <a href="../apidoc/ol.Attribution.html" title="API documentation for ol.Attribution">ol.Attribution</a> -->
        <a href="v3.12.1/apidoc/ol.Attribution.html" title="API documentation for ol.Attribution">ol.Attribution</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.Map.Feature" title="API documentation for ol.Feature">ol.Feature</a> -->
        <a href="v3.12.1/apidoc/ol.Feature.html" title="API documentation for ol.Feature">ol.Feature</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.Map.html" title="API documentation for ol.Map">ol.Map</a> -->
        <a href="v3.12.1/apidoc/ol.Map.html" title="API documentation for ol.Map">ol.Map</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.View.html" title="API documentation for ol.View">ol.View</a> -->
        <a href="v3.12.1/apidoc/ol.View.html" title="API documentation for ol.View">ol.View</a>
       </li>,
       <li>
        <!--<a href="../apidoc/ol.geom.LineString.html" title="API documentation for ol.geom.LineString">ol.geom.LineString</a> -->
        <a href="v3.12.1/apidoc/ol.geom.LineString.html" title="API documentation for ol.geom.LineString">ol.geom.LineString</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.layer.Tile.html" title="API documentation for ol.layer.Tile">ol.layer.Tile</a> -->
        <a href="v3.12.1/apidoc/ol.layer.Tile.html" title="API documentation for ol.layer.Tile">ol.layer.Tile</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.layer.Vector.html" title="API documentation for ol.layer.Vector">ol.layer.Vector</a> -->
        <a href="v3.12.1/apidoc/ol.layer.Vector.html" title="API documentation for ol.layer.Vector">ol.layer.Vector</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.proj.html" title="API documentation for ol.proj">ol.proj</a> -->
        <a href="v3.12.1/apidoc/ol.proj.html" title="API documentation for ol.proj">ol.proj</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.source.Stamen.html" title="API documentation for ol.source.Stamen">ol.source.Stamen</a> -->
        <a href="v3.12.1/apidoc/ol.source.Stamen.html" title="API documentation for ol.source.Stamen">ol.source.Stamen</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.source.Vector.html" title="API documentation for ol.source.Vector">ol.source.Vector</a> -->
        <a href="v3.12.1/apidoc/ol.source.Vector.html" title="API documentation for ol.source.Vector">ol.source.Vector</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.style.Stroke.html" title="API documentation for ol.style.Stroke">ol.style.Stroke</a> -->
        <a href="v3.12.1/apidoc/ol.style.Stroke.html" title="API documentation for ol.style.Stroke">ol.style.Stroke</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.style.Style.html" title="API documentation for ol.style.Style">ol.style.Style</a> -->
        <a href="v3.12.1/apidoc/ol.style.Style.html" title="API documentation for ol.style.Style">ol.style.Style</a>
       </li>
      </ui>
     </div>
    </div>
   </div>
   <div class="row-fluid">
    <div id="source-controls">
     <a id="copy-button">
      <i class="fa fa-clipboard"></i> Copy
     </a>
     <a id="jsfiddle-button">
      <i class="fa fa-jsfiddle"></i> Edit
     </a>
    </div>
    <form method="POST" id="jsfiddle-form" target="_blank" action="http://jsfiddle.net/api/post/jquery/1.11.0/">
    <textarea class="hidden" name="js">
// --- 省略 ---
&lt;/html&gt;</code></pre>
   </div>
  </div>
  <!--
  <script src="./resources/common.js"></script>
  <script src="./resources/prism/prism.min.js"></script>
  -->
  <!-- ディレクトリ修正
   CommonJS と
   prism.js
 -->
  <script src="v3.12.1/examples/resources/common.js"></script>
  <script src="v3.12.1/examples/resources/prism/prism.min.js"></script>
  <!-- 
  <script src="loader.js?id=flight-animation"></script>
  -->
  <!-- ファイル修正 -->  <!-- ディレクトリ修正 -->
  <script src="loader.js?id=2145-ol3ex"></script>
  </body>
</html>


COMMONJS は

COMMONJS
http://webpack.github.io/docs/commonjs.html

に、次のようにあります。

The CommonJS group defined a module format to solve JavaScript scope issues by making sure each module is executed in its own namespace.
This is achieved by forcing modules to explicitly export those variables it wants to expose to the “universe”, and also by defining those other modules required to properly work.
To achieve this CommonJS give you two tools:
the require() function, which allows to import a given module into the current scope.
the module object, which allows to export something from the current scope.

CommonJSグループは、それ自身の名前空間内で実行されている各モジュールを確認することによって、JavaScriptのスコープ問題を解決するためのモジュールフォーマットを定義しました。
これは、それが「universe(?)」に公開したい変数を明示的にエクスポートするモジュールを強制することによって、同じように、正常に動作するのに必要な他のモジュールを定義することによって、達成されます。
この CommonJS を達成するために2つのツールを与えます:
require()関数、指定したモジュールを現在のスコープにインポートすることができます。
モジュールオブジェクト、現在のスコープからエクスポートすることができます。


Prism は、

Prism
http://prismjs.com/

に、次のようにあります。

Prism is a lightweight, extensible syntax highlighter, built with modern web standards in mind. It’s a spin-off from Dabblet and is tested there daily by thousands.
Prismは、最新のWeb標準に構築されたことを考慮し軽量で拡張可能なシンタックスハイライトです。それは Dabblet からスピンオフで、何千人も日々そこで試験されています。


ZeroClipboard は

ZeroClipboard v2.x
http://zeroclipboard.org/

に、次のようにあります。

The ZeroClipboard library provides an easy way to copy text to the clipboard using an invisible Adobe Flash movie and a JavaScript interface.
ZeroClipboard ライブラリは、見えない Adobe Flash ムービーとJavaScript のインターフェイスを使用してテキストをクリップボードにコピーする簡単な方法を提供します。

Debian 8 では動作しませんでした。ボタンを右クリックしたときに flash のコンテキストメニューが表示されると動作しています。

2015年11月30日月曜日

2 - ol3.11ex 134b - Animate a feature movement 2

「feature-move-animation.js(2134-ol3ex.js)」は、マップを表示するための JavaScript ファイルです。

「2134-ol3ex.js」
// This long string is placed here due to jsFiddle 
// limitations. It is usually loaded with AJAX.
// この長い文字列は、jsFiddleの制限が原因でここに置かれています。
// これは通常、Ajaxを使ってロードされます。
var polyline = [
  (省略)
].join('');
/** Array.prototype.join()
 * join() メソッドは、配列のすべての要素を繋いで文字列にします。
 * (MDN[https://developer.mozilla.org/ja/docs/Web/
 * JavaScript/Reference/Global_Objects/Array/join])
 */
var route = /** @type {ol.geom.LineString} */ (new ol.format.Polyline({
/** @type 
 * 値のタイプ(型)の説明 - 式などで表示
 * (@use JSDoc[http://usejsdoc.org/]より)
 */
/** ol.format.Polyline
 * Feature format for reading and writing data in the 
 * Encoded Polyline Algorithm Format.
 * Encoded Polyline Algorithm Format でデータを読み書きす
 * るためのフィーチャフォーマット。
 * (ol3 API)
 */
 factor: 1e6
 /** factor
  * The factor by which the coordinates values will be 
  * scaled. Default is 1e5. Required.
  * 座標値がスケーリングされることによるファクタ。
  * デフォルトは 1E5。必須。
  * (ol3 API)
  */
}).readGeometry(polyline, {
/** readGeometry(source, opt_options)
 * Read the geometry from the source.
 * ソースからジオメトリを読み込みます。
 * (ol3 API)
 */
 dataProjection: 'EPSG:4326',
 /** dataProjection
  * Projection of the data we are reading. If not provided, 
  * the projection will be derived from the data (where 
  * possible) or the defaultDataProjection of the format 
  * is assigned (where set). If the projection can not be 
  * derived from the data and if no defaultDataProjection 
  * is set for a format, the features will not be 
  * reprojected.
  * 読み込んでいるデータの投影。提供されていない場合、投影は
  * (可能な場合)データに由来し、または、フォーマットの 
  * defaultDataProjection は(セットの場合)割り当てられま
  * す。します。投影がデータに由来できない場合、および、
  * defaultDataProjection がフォーマットに設定されていない
  * 場合、フィーチャが再投影されることはありません。
  * (ol3 API)
  */
 featureProjection: 'EPSG:3857'
 /** featureProjection
  * Projection of the feature geometries created by the 
  * format reader. If not provided, features will be 
  * returned in the dataProjection.
  * フォーマットリーダーによって作成されたフィーチャジオメトリ
  * の投影。提供されていない場合、フィーチャが dataProjection 
  * に返されます。
  * (ol3 API)
  */
}));
var routeCoords = route.getCoordinates();
/** getCoordinates()
 * Return the coordinates of the linestring.
 * ラインストリングの座標を返します
 */
var routeLength = routeCoords.length;
var routeFeature = new ol.Feature({
/** ol.Feature
 * A vector object for geographic features with a geometry 
 * and other attribute properties, similar to the features 
 * in vector file formats like GeoJSON.
 * GeoJSONのようなベクトルファイル形式のフィーチャに類似した、
 * ジオメトリとその他の属性プロパティを持つ地物フィーチャのた
 * めのベクトルオブジェクト。(ol3 API)
 */
 type: 'route',
 geometry: route
});
var geoMarker = new ol.Feature({
 type: 'geoMarker',
 geometry: new ol.geom.Point(routeCoords[0])
 /** ol.geom.Point
  * Point geometry.(ol3 API)
  */
});
var startMarker = new ol.Feature({
 type: 'icon',
 geometry: new ol.geom.Point(routeCoords[0])
});
var endMarker = new ol.Feature({
 type: 'icon',
 geometry: new ol.geom.Point(routeCoords[routeLength - 1])
});
var styles = {
 'route': new ol.style.Style({
 /** ol.style.Style 
  * Container for vector feature rendering styles. Any 
  * changes made to the style or its children through 
  * set*() methods will not take effect until the feature 
  * or layer that uses the style is re-rendered.
  * ベクタフィーチャがスタイルを描画するためのコンテナ。
  * スタイルや set*() メソッドを通じてその子に加えられた変
  * 更は、スタイルを使用するフィーチャまたはレイヤが再レン
  * ダリングされるまで有効になりません。
  * (ol3 API[説明は Stable Only のチェックを外すと表示])
  */
  stroke: new ol.style.Stroke({
  /** ol.style.Stroke 
   * Set stroke style for vector features. 
   * Note that the defaults given are the Canvas defaults, 
   * which will be used if option is not defined. 
   * The get functions return whatever was entered in the 
   * options;  they will not return the default.
   * ベクタフィーチャのためのストロークスタイルの設定。
   * デフォルトは、オプションが定義されていない場合に使用され
   * る Canvas のデフォルトを与えられることに注意してください。
   * GET 関数は、オプションで入力されたものはすべて返します。
   * それらはデフォルトを返しません。
   * (ol3 API[説明は Stable Only のチェックを外すと表示])
   */
   width: 6, color: [237, 212, 0, 0.8]
  })
 }),
 'icon': new ol.style.Style({
  image: new ol.style.Icon({
  /** ol.style.Icon 
   * Set icon style for vector features.
   * ベクタフィーチャのアイコンスタイルを設定します。
   * (ol3 API[説明は Stable Only のチェックを外すと表示])
   */
   anchor: [0.5, 1],
   // src: 'data/icon.png'
   src: 'v3.11.2/examples/data/icon.png'
  })
 }),
 'geoMarker': new ol.style.Style({
  image: new ol.style.Circle({
  /** ol.style.Circle
   * Set circle style for vector features.
   * ベクタフィーチャの円のスタイルを設定。
   * (ol3 API[説明は Stable Only のチェックを外すと表示])
   */
   radius: 7,
   snapToPixel: false,
   /** snapToPixel
    * If true integral numbers of pixels are used as the 
    * X and Y pixel coordinate when drawing the circle 
    * in the output canvas. If false fractional numbers 
    * may be used. Using true allows for "sharp" rendering 
    * (no blur), while using false allows for "accurate" 
    * rendering. Note that accuracy is important if the 
    * circle's position is animated. Without it, the 
    * circle may jitter noticeably. Default value is true.
    * true の場合、ピクセル整数は、出力キャンバスに円を描画す
    * るとき、XとYピクセル座標として使用されます。false の場
    * 合、分数を使用することができます。true を使用すると「
    * シャープ」レンダリング(ぼかしなし)を可能にし、false 
    * 使用すると「正確」なレンダリングを可能にします。円の位
    * 置がアニメーション化されている場合は、その正確さが重要
    * であることに注意してください。それがなければ、円が著し
    * く乱れることがあります。デフォルト値は true です。
    * (ol3 API[説明は Stable Only のチェックを外すと表示])
    */
   fill: new ol.style.Fill({color: 'black'}),
   /** ol.style.Fill 
    * Set fill style for vector features.
    * ベクタフィーチャの塗りつぶしスタイルを設定。(ol3 API)
    */
   stroke: new ol.style.Stroke({
    color: 'white', width: 2
   })
  })
 })
};
var vectorLayer = new ol.layer.Vector({
/** ol.layer.Vector
 * Vector data that is rendered client-side.
 * クライアント側で描画されたベクタデータ。(ol3 API)
 */
 source: new ol.source.Vector({
 /** ol.source.Vector 
  * Provides a source of features for vector layers. Vector 
  * features provided by this source are suitable for 
  * editing. See ol.source.VectorTile for vector data that 
  * is optimized for rendering.
  * ベクタレイヤのフィーチャのソースを提供します。このソースが
  * 提供するベクトルのフィーチャは、編集に適しています。レンダ
  * リングのために最適化されたベクトルデータのための 
  * ol.source.VectorTile を参照してください。(ol3 API)
  */
  features: [routeFeature, geoMarker, startMarker, endMarker]
 }),
 style: function(feature, resolution) {
 // hide geoMarker if animation is active
 // アニメーションがアクティブである場合 geoMarker を隠します
  if (animating && feature.get('type') === 'geoMarker') {
  /** get(key)
   * Gets a value.
   * 値を取得します。(ol3 API)
   */
   return [];
  }
  return [styles[feature.get('type')]];
 }
});
var center = [-5639523.95, -3501274.52];
var map = new ol.Map({
 target: document.getElementById('map'),
 loadTilesWhileAnimating: true,
 /** loadTilesWhileAnimating:
  * When set to true, tiles will be loaded during 
  * animations. This may improve the user experience, but 
  * can also make animations stutter on devices with slow 
  * memory. Default is `false`.
  * true に設定すると、タイルは、アニメーションの間にロード
  * されます。これは、ユーザーエクスペリエンスを向上させるこ
  * とだけでなく、アニメーションが遅いメモリを搭載したデバイ
  * ス上で途切れ途切れにすることができます。
  * デフォルトは `false` です。(ol3 API)
  */
 view: new ol.View({
  center: center,
  zoom: 10,
  minZoom: 2,
  maxZoom: 19
 }),
 layers: [
  new ol.layer.Tile({
  /** ol.layer.Tile 
   * For layer sources that provide pre-rendered, tiled 
   * images in grids that are organized by zoom levels for 
   * specific resolutions. 
   * プリレンダリング(事前描画)を提供するレイヤソースのため
   * の、特定の解像度でのズームレベルによって編成されているグ
   * リッドのタイルイメージ。(ol3 API)
   */
   source: new ol.source.BingMaps({
   /** ol.source.BingMaps
    * Layer source for Bing Maps tile data.
    * Bing Maps タイルデータのレイヤソース。(ol3 API)
    */
    imagerySet: 'AerialWithLabels',
    key: 'Ak-dzM...(省略)'
   })
  }),
  vectorLayer
 ]
});
var moveFeature = function(event) {
 var vectorContext = event.vectorContext;
 /** vectorContext{ol.render.VectorContext} 
  * For canvas, this is an instance of 
  * ol.render.canvas.Immediate.
  * キャンバスの場合、これは  ol.render.canvas.Immediate 
  * のインスタンスです。
  * (ol3 API[説明は Stable Only のチェックを外すと表示])
  */
 var frameState = event.frameState;
  /** frameState{olx.FrameState}
   * The frame state at the time of the event.
   * イベント時のフレーム状態。
   * (ol3 API[説明は Stable Only のチェックを外すと表示])
   */
 if (animating) {
  var elapsedTime = frameState.time - now;
  // here the trick to increase speed is to jump some 
  // indexes on lineString coordinates
  // ここで速度を向上させるコツは、座標をラインストリング上のい
  // くつかのインデックスをジャンプすることです
  var index = Math.round(speed * elapsedTime / 1000);
  /** Math.round()
   * 引数として与えた数を四捨五入して、最も近似の整数を返します。
   * (MDN[https://developer.mozilla.org/ja/docs/Web/
   * JavaScript/Reference/Global_Objects/Math/round])
   */
  if (index >= routeLength) {
   stopAnimation(true);
   return;
  }
  var currentPoint = new ol.geom.Point(routeCoords[index]);
  var feature = new ol.Feature(currentPoint);
  vectorContext.drawFeature(feature, styles.geoMarker);
  /** drawFeature(()
   * Render a feature into the canvas. In order to 
   * respect the zIndex of the style this method draws 
   * asynchronously and thus after calls to 
   * drawXxxxGeometry have been finished, effectively 
   * drawing the feature on top of everything else. You 
   * probably should be using ol.layer.Vector instead 
   * of calling this method directly.
   * キャンバスにフィーチャをレンダリングします。 スタイルの 
   * zIndex を尊重するために、このメソッドは非同期的に描画
   * します。これにより、終了した drawXxxxGeometry への呼
   * び出した後に、他のすべての上のフィーチャを効果的に描画し
   * ます。このメソッドを直接呼び出す代わりに、おそらく 
   * ol.layer.Vector  を使用する必要があります。
   * (ol3 API[説明は Stable Only のチェックを外すと表示])
   */
 }
 // tell OL3 to continue the postcompose animation
 // postcompose animation を継続するために OL3 に伝えます
 map.render();
 /** render()
  * Request a map rendering (at the next animation 
  * frame).
  * (次のアニメーションフレームで)map 描画を要求します。
  * (ol3 API)
  */
};
function startAnimation() {
 if (animating) {
  stopAnimation(false);
 } else {
  animating = true;
  now = new Date().getTime();
  /** Date
   * 日付や時刻を扱うことが可能な、JavaScript の Date 
   * インスタンスを生成します。
   * (MDN[https://developer.mozilla.org/ja/docs/Web/
   * JavaScript/Reference/Global_Objects/Date])
   */
  /** Date.prototype.getTime()
   * ユニバーサル時間に従い、指定された日付の時刻に対応する数
   * 値を返します。
   * GetTime メソッドによって返される値は、1970 年 1 月 1 日 
   * 00:00:00 UTC からの経過ミリ秒です。このメソッドは、日付
   * と時刻を別の Date オブジェクトに割り当てるために使用でき
   * ます。
   * (MDN[https://developer.mozilla.org/ja/docs/Web/
   * JavaScript/Reference/Global_Objects/Date/getTime])
   */
  speed = speedInput.value;
  startButton.textContent = 'Cancel Animation';
  /** Node.textContent
   * The Node.textContent property represents the text 
   * content of a node and its descendants.
   * Node.textContentプロパティは、ノードとノードの子孫のテキ
   * ストの内容を表します。
   * (MDN[https://developer.mozilla.org/en-US/docs/
   * Web/API/Node/textContent])
   */
  // hide geoMarker
  // geoMarker を隠します
  geoMarker.setStyle(null);
  /** setStyle(style)
   * Set the style for the feature. This can be a single 
   * style object, an array of styles, or a function that 
   * takes a resolution and returns an array of styles. If 
   * it is null the feature has no style (a null style).
   * フィーチャのスタイルを設定します。これは、単一のスタイルオ
   * ブジェクト、スタイルの配列、または解像度をとり、スタイルの
   * 配列を返す関数とすることができます。null の場合、フィー
   * チャは、スタイルなし(null のスタイル)を持ちます。
   * (ol3 API)
   */
  // just in case you pan somewhere else
  // 念のために、どこか他にパンします。
  map.getView().setCenter(center);
  /** getView()
   * Get the view associated with this map. A view 
   * manages properties such as center and resolution.
   * このマップと関連するビューを取得します。ビューは、中心
   * や解像度のような属性を管理します。
   * Return: The view that controls this map.(ol3 API)
   */
  /** setCenter()
   * Set the center of the current view.
   * 現在のビューの中心を設定します。(ol3 API)
   */
  map.on('postcompose', moveFeature);
  /** on(type, listener, opt_this)
   * Listen for a certain type of event.
   * あるタイプのイベントをリッスンします。(ol3 API)
   */
  map.render();
 }
}
/**
 * @param {boolean} ended end of animation.
 */
/** 「@param」
 * The @param tag provides the name, type, and 
 * description of a function parameter.
 * The @param tag requires you to specify the name of 
 * the parameter you are documenting. You can also 
 * include the parameter's type, enclosed in curly 
 * brackets, and a description of the parameter.
 * @paramタグは、関数パラメータの名前と型、説明を提供します。
 * @paramタグを使用すると、文書化されたパラメータの名前を
 * 指定する必要があります。また、パラメータのタイプと、中括弧
 * で囲まれたおよびパラメータの説明を含めることができます。
 * (@use JSDoc [http://usejsdoc.org/tags-param.html])
 */
function stopAnimation(ended) {
 animating = false;
 startButton.textContent = 'Start Animation';
 // if animation cancelled set the marker at the beginning
 // アニメーションキャンセルされた場合、先頭にマーカーを設定
 var coord = ended ? routeCoords[routeLength - 1] : routeCoords[0];
 /** 条件演算子 condition ? expr1 : expr2 
  * condition: true か false かを評価する条件文です。
  * expr1, expr2: 各々の値の場合に実行する式です。
  * condition が true の場合、演算子は expr1 の値を選択します。
  * そうでない場合は expr2 の値を選択します。
  * (MDN[https://developer.mozilla.org/ja/docs/Web/
  * JavaScript/Guide/Expressions_and_Operators])
  */
 /** @type {ol.geom.Point} */ (geoMarker.getGeometry())
 /** getGeometry()
  * Get the feature's default geometry. A feature may have 
  * any number of named geometries. The "default" geometry 
  * (the one that is rendered by default) is set when 
  * calling ol.Feature#setGeometry.
  * フィーチャのデフォルトのジオメトリを取得します。フィーチャ
  * は、任意の数の指定のジオメトリのを有することができます。 
  * 「デフォルト」のジオメトリ(デフォルトでレンダリングされる
  * もの)が ol.Feature#setGeometry を呼び出すときに設定され
  * ています。(ol3 API)
  */
  .setCoordinates(coord);
  /** setCoordinates(coordinates, opt_layout)
   * Set the coordinate of the point.
   * 点の座標を設定します。
   * (ol3 API)
   */
 //remove listener
 // リスナを削除
 map.un('postcompose', moveFeature);
}
var speed, now;
var animating = false;
var speedInput = document.getElementById('speed');
var startButton = document.getElementById('start-animation');
startButton.addEventListener('click', startAnimation, false);
/** EventTarget.addEventListener
 * addEventListener は、 1 つのイベントターゲットにイベント 
 * リスナーを1つ登録します。イベントターゲットは、ドキュメント
 * 上の単一のノード、ドキュメント自身、ウィンドウ、あるいは、
 * XMLHttpRequest です。
 *(MDN[https://developer.mozilla.org/ja/docs/Web/API/
 * EventTarget.addEventListener])
 */

2 - ol3.11ex 134a - Animate a feature movement 1

「Animate a feature movement (feature-move-animation.html)」を参考に地図を表示してみます。
説明に次のようにあります。

This example shows how to use postcompose and vectorContext to animate a (marker) feature along a line. In this example an encoded polyline is being used.
この例では、線に沿って(マーカー)フィーチャをアニメーション化する postcompose と vectorContext を使用する方法を示します。この例では、符号化されたポリラインを使用しています。

HTML ファイルの作成
a Eclipse のメニューの「ファイル」->「ファイルを開く」をクリックします。





b 「ファイルを開く」ウィンドウで、「user」->「mapsite」->「ol3proj」->「v3.11.2」->「examples」->「feature-move-animation.html」をクリックして選択し、「OK」ボタンをクリックします。
同じように「feature-move-animation.js」を開きます。





c メニューの「ファイル」->「新規」 -> 「ファイル」をクリックします。



d 「ファイル」ウィンドウで「ol3proj」をクリックして選択し、「ファイル名」を「2134-ol3ex.html」と入力し、「次へ」ボタンをクリックします。








e 「File Template」ウィンドウで「HTML 5 Template」をクリックして選択し、「OK」ボタンをクリックします。











f 「feature-move-animation.html」の内容をコピーして「2134-ol3ex.html」に貼り付け、修正します。
g 同じように、新規に「2134-ol3ex.js」ファイルを作成し、「File Template」ウィンドウで「JavaScript Template」をクリックして選択し、「完了」ボタンをクリックして、「feature-move-animation.js」の内容をコピーして貼り付け、修正します。「feature-move-animation-require.js」も「2134-ol3ex-require.js」に貼り付けます。

「2134-ol3ex.html」
<!doctype html>
<html lang="en">
 <head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="chrome=1">
  <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" type="text/css">
  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-combined.min.css" type="text/css">
  <!--
  <link rel="stylesheet" href="../css/ol.css" type="text/css">
  <link rel="stylesheet" href="./resources/layout.css" type="text/css">

  <link rel="stylesheet" href="./resources/prism/prism.css" type="text/css">
  <script src="./resources/zeroclipboard/ZeroClipboard.min.js"></script>
  「resources」の位置が変わりました。
  -->
  <!-- ディレクトリ修正 -->
  <link rel="stylesheet" href="v3.11.2/css/ol.css" type="text/css">
  <link rel="stylesheet" href="v3.11.2/examples/resources/layout.css" type="text/css">

  <link rel="stylesheet" href="v3.11.2/examples/resources/prism/prism.css" type="text/css">
  <script src="v3.11.2/examples/resources/zeroclipboard/ZeroClipboard.min.js"></script>
  <title&gtAnimate a feature movement</title>
 </head>
 <body>
  <!-- 
  bootstrap-combined.min.css, ol.css, layout.css,
  CSSファイルで設定されたセレクタを使用。
  -->
  <header class="navbar" role="navigation">
   <div class="container" id="navbar-inner-container">
    <!--
    <a class="navbar-brand" href="./"><img src="./resources/logo-70x70.png"> OpenLayers 3 Examples</a>
    -->
    <!-- ディレクトリ修正 -->
    <a class="navbar-brand" href="v3.11.2/examples/"><img src="v3.11.2/examples/resources/logo-70x70.png"> OpenLayers 3 Examples</a>
   </div>
  </header>
  <div class="container-fluid">
   <div class="row-fluid">
    <div class="span12">
     <div id="map" class="map"></div>
    </div>
   </div>
   <div class="row-fluid">
    <div class="span12">
     <label for="speed">
      speed:&nbsp;
      <input id="speed" type="range" min="10" max="999" step="10" value="60">
     </label>
     <button id="start-animation">Start Animation</button>
    </div>
   </div>
   <div class="row-fluid">
    <div class="span12">
     <h4 id="title">Animate a feature movement</h4>
     <p id="shortdesc">Demonstrates how to move a feature  
      along a line.</p>
     <div id="docs"><p>This example shows how to use 
      <b>postcompose</b> and <b>vectorContext</b> to animate
      a (marker) feature along a line. In this example an 
      encoded polyline is being used.</p>
     </div>
     <div id="tags">animation, feature, postcompose, polyline</div>
     <div id="api-links">Related API documentation: 
      <ul class="inline">
       <li>
        <!-- <a href="../apidoc/ol.Feature.html" title="API documentation for ol.Feature">ol.Feature</a> -->
        <a href="v3.11.2/apidoc/ol.Feature.html" title="API documentation for ol.Feature">ol.Feature</a>
       </li>,
       <li>
       <!-- <a href="../apidoc/ol.Map.html" title="API documentation for ol.Map">ol.Map</a> -->
        <a href="v3.11.2/apidoc/ol.Map.html" title="API documentation for ol.Map">ol.Map</a>
       </li>,
       <li>
       <!-- <a href="../apidoc/ol.View.html" title="API documentation for ol.View">ol.View</a> -->
        <a href="v3.11.2/apidoc/ol.View.html" title="API documentation for ol.View">ol.View</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.format.Polyline.html" title="API documentation for ol.format.Polyline">ol.format.Polyline</a> -->
        <a href="v3.11.2/apidoc/ol.format.Polyline.html" title="API documentation for ol.format.Polyline">ol.format.Polyline</a>
       </li>,
       <li>
         <!-- <a href="../apidoc/ol.geom.Point.html" title="API documentation for ol.geom.Point">ol.geom.Point</a> -->
         <a href="v3.11.2/apidoc/ol.geom.Point.html" title="API documentation for ol.geom.Point">ol.geom.Point</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.layer.Tile.html" title="API documentation for ol.layer.Tile">ol.layer.Tile</a> -->
        <a href="v3.11.2/apidoc/ol.layer.Tile.html" title="API documentation for ol.layer.Tile">ol.layer.Tile</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.layer.Vector.html" title="API documentation for ol.layer.Vector">ol.layer.Vector</a> -->
        <a href="v3.11.2/apidoc/ol.layer.Vector.html" title="API documentation for ol.layer.Vector">ol.layer.Vector</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.source.BingMaps.html" title="API documentation for ol.source.BingMaps">ol.source.BingMaps</a> -->
        <a href="v3.11.2/apidoc/ol.source.BingMaps.html" title="API documentation for ol.source.BingMaps">ol.source.BingMaps</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.source.Vector.html" title="API documentation for ol.source.Vector">ol.source.Vector</a> -->
        <a href="v3.11.2/apidoc/ol.source.Vector.html" title="API documentation for ol.source.Vector">ol.source.Vector</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.style.Circle.html" title="API documentation for ol.style.Circle">ol.style.Circle</a> -->
        <a href="v3.11.2/apidoc/ol.style.Circle.html" title="API documentation for ol.style.Circle">ol.style.Circle</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.style.Fill.html" title="API documentation for ol.style.Fill">ol.style.Fill</a> -->
        <a href="v3.11.2/apidoc/ol.style.Fill.html" title="API documentation for ol.style.Fill">ol.style.Fill</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.style.Icon.html" title="API documentation for ol.style.Icon">ol.style.Icon</a> -->
        <a href="v3.11.2/apidoc/ol.style.Icon.html" title="API documentation for ol.style.Icon">ol.style.Icon</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.style.Stroke.html" title="API documentation for ol.style.Stroke">ol.style.Stroke</a> -->
        <a href="v3.11.2/apidoc/ol.style.Stroke.html" title="API documentation for ol.style.Stroke">ol.style.Stroke</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.style.Style.html" title="API documentation for ol.style.Style">ol.style.Style</a> -->
        <a href="v3.11.2/apidoc/ol.style.Style.html" title="API documentation for ol.style.Style">ol.style.Style</a>
       </li>
      </ui>
     </div>
   </div>
  </div>
  <div class="row-fluid">
    <div id="source-controls">
     <a id="copy-button">
      <i class="fa fa-clipboard"></i> Copy
     </a>
     <a id="jsfiddle-button">
      <i class="fa fa-jsfiddle"></i> Edit
     </a>
    </div>
    <form method="POST" id="jsfiddle-form" target="_blank" action="http://jsfiddle.net/api/post/jquery/1.11.0/">
    <textarea class="hidden" name="js">
// --- 省略 ---
&lt;/html&gt;</code></pre>
   </div>
  </div>
  <script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
  <!--
  <script src="./resources/common.js"></script>
  <script src="./resources/prism/prism.min.js"></script>
  -->
  <!-- ディレクトリ修正
   CommonJS と
   prism.js
 -->
  <script src="v3.11.2/examples/resources/common.js"></script>
  <script src="v3.11.2/examples/resources/prism/prism.min.js"></script>
  <!-- 
  <script src="loader.js?id=feature-move-animation"></script>
  -->
  <!-- ファイル修正 -->  <!-- ディレクトリ修正 -->
  <script src="loader.js?id=2134-ol3ex"></script>
  </body>
</html>


COMMONJS は

COMMONJS
http://webpack.github.io/docs/commonjs.html

に、次のようにあります。

The CommonJS group defined a module format to solve JavaScript scope issues by making sure each module is executed in its own namespace.
This is achieved by forcing modules to explicitly export those variables it wants to expose to the “universe”, and also by defining those other modules required to properly work.
To achieve this CommonJS give you two tools:
the require() function, which allows to import a given module into the current scope.
the module object, which allows to export something from the current scope.

CommonJSグループは、それ自身の名前空間内で実行されている各モジュールを確認することによって、JavaScriptのスコープ問題を解決するためのモジュールフォーマットを定義しました。
これは、それが「universe(?)」に公開したい変数を明示的にエクスポートするモジュールを強制することによって、同じように、正常に動作するのに必要な他のモジュールを定義することによって、達成されます。
この CommonJS を達成するために2つのツールを与えます:
require()関数、指定したモジュールを現在のスコープにインポートすることができます。
モジュールオブジェクト、現在のスコープからエクスポートすることができます。


Prism は、

Prism
http://prismjs.com/

に、次のようにあります。

Prism is a lightweight, extensible syntax highlighter, built with modern web standards in mind. It’s a spin-off from Dabblet and is tested there daily by thousands.
Prismは、最新のWeb標準に構築されたことを考慮し軽量で拡張可能なシンタックスハイライトです。それは Dabblet からスピンオフで、何千人も日々そこで試験されています。


ZeroClipboard は

ZeroClipboard v2.x
http://zeroclipboard.org/

に、次のようにあります。

The ZeroClipboard library provides an easy way to copy text to the clipboard using an invisible Adobe Flash movie and a JavaScript interface.
ZeroClipboard ライブラリは、見えない Adobe Flash ムービーとJavaScript のインターフェイスを使用してテキストをクリップボードにコピーする簡単な方法を提供します。

Debian 8 では動作しませんでした。ボタンを右クリックしたときに flash のコンテキストメニューが表示されると動作しています。

2015年7月9日木曜日

2 - ol3.7ex 123b - Feature animation example 2

「feature-animation.js(2123-ol3ex.js)」は、マップを表示するための JavaScript ファイルです。

「2123-ol3ex.js」
var map = new ol.Map({
 layers: [
  new ol.layer.Tile({
  /** ol.layer.Tile 
   * For layer sources that provide pre-rendered, tiled 
   * images in grids that are organized by zoom levels for 
   * specific resolutions. 
   * プリレンダリング(事前描画)を提供するレイヤソースのための、
   * 特定の解像度でのズームレベルによって編成されているグリッドの
   * タイルイメージ。(ol3 API)
   */
   source: new ol.source.OSM({
   /** ol.source.OSM 
    * Layer source for the OpenStreetMap tile server.
    * OpenStreetMap タイルサーバのレイヤソース。(ol3 API)
    */
    wrapX: false
   /** wrapX:
    * Whether to wrap the world horizontally. Default is 
    * false.
    * 水平に世界を覆うかどうかを設定します。デフォルトはfalse
    * です。
    * (ol3 API[説明は Stable Only のチェックを外すと表示])
    */
   })
  })
 ],
 controls: ol.control.defaults({
 /** controls
  * Controls initially added to the map. 
  * If not specified, ol.control.defaults() is used.
  * 初期設定で、マップに追加されたコントロール。
  * 明示されていなければ、ol.control.defaults() が使用されます。
  * (ol3 API)
  */
 /** ol.control.defaults()
  * デフォルトでは、マップに含まコントロールのセット。
  * 特に設定しない限り、これは、以下の各コントロールの
  * インスタンスを含むコレクションを返します。(ol3 API)
  * ol.control.Zoom, ol.control.Rotate, ol.control.Attribution
  */
  attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
  /** @type 
   * 値のタイプ(型)の説明 - 式などで表示
   * (@use JSDoc[http://usejsdoc.org/]より)
   */
   collapsible: false // 折りたたみ
  })
 }),
 renderer: common.getRendererFromQueryString(),
// 'common.js' により URL にある renderer を返します
 target: 'map',
 view: new ol.View({
  center: [0, 0],
  zoom: 1
 })
});
var source = new ol.source.Vector({
 /** ol.source.Vector 
  * Provides a source of features for vector layers.
  * ベクタレイヤのフィーチャのソースを提供します。(ol3 API)
  */
 wrapX: false
});
var vector = new ol.layer.Vector({
/** ol.layer.Vector
 * Vector data that is rendered client-side.
 * クライアント側で描画されたベクタデータ。(ol3 API)
 */
 source: source
});
map.addLayer(vector);
function addRandomFeature() {
 var x = Math.random() * 360 - 180;
 /** Math.random()
  * The Math.random() function returns a floating-point, 
  * pseudo-random number in the range [0, 1) that is, 
  * from 0 (inclusive) up to but not including 1 
  * (exclusive), which you can then scale to your 
  * desired range. The implementation selects the 
  * initial seed to the random number generation 
  * algorithm; it cannot be chosen or reset by the 
  * user.
  * Math.random() 関数は浮動小数点を返し、0 と 1 の範囲の
  * 擬似乱数、すなわち 0 以上 1 未満、で、任意の範囲に合わせ
  * ることができます。インプリメンテーションは、乱数発生アル
  * ゴリズムのためにイニシャルシードを選択しますが、ユーザが
  * 選んだりリセットできません。
  * (MDN[https://developer.mozilla.org/en-US/docs/Web/
  * JavaScript/Reference/Global_Objects/Math/random])
  */
 var y = Math.random() * 180 - 90;
 var geom = new ol.geom.Point(ol.proj.transform([x, y],
  'EPSG:4326', 'EPSG:3857'));
 /** ol.geom.Point
  * Point geometry.(ol3 API)
  */
 /** ol.proj.transform(coordinate, source, destination)
  * Transforms a coordinate from source projection to 
  * destination projection. This returns a new coordinate 
  * (and does not modify the original).
  * ソース投影から変換先投影に座標変換します。これは、新しい座標
  * を返します(オリジナルを変更しません)。(ol3 API)
  */
 var feature = new ol.Feature(geom);
 /** ol.Feature
  * A vector object for geographic features with a 
  * geometry and other attribute properties, similar 
  * to the features in vector file formats like GeoJSON.
  * GeoJSONのようなベクトルファイル形式のフィーチャに類似した、
  * ジオメトリとその他の属性プロパティを持つ地物フィーチャのため
  * のベクトルオブジェクト。(ol3 API)
  */
 source.addFeature(feature);
}
var duration = 3000;
function flash(feature) {
 var start = new Date().getTime();
 /** Date
  * 日付や時刻を扱うことが可能な、JavaScript の Date 
  * インスタンスを生成します。
  * (MDN[https://developer.mozilla.org/ja/docs/Web/
  * JavaScript/Reference/Global_Objects/Date])
  */
 /** Date.prototype.getTime()
  * ユニバーサル時間に従い、指定された日付の時刻に対応する数
  * 値を返します。
  * GetTime メソッドによって返される値は、1970 年 1 月 1 日 
  * 00:00:00 UTC からの経過ミリ秒です。このメソッドは、日付
  * と時刻を別の Date オブジェクトに割り当てるために使用できま
  * す。
  * (MDN[https://developer.mozilla.org/ja/docs/Web/
  * JavaScript/Reference/Global_Objects/Date/getTime])
  */
 var listenerKey;
 function animate(event) {
  var vectorContext = event.vectorContext;
  /** vectorContext{ol.render.VectorContext}
   * For canvas, this is an instance of 
   * ol.render.canvas.Immediate.
   * キャンバスの場合、これは ol.render.canvas.Immediate 
   * のインスタンスです。
   * (ol3 API[説明は Stable Only のチェックを外すと表示])
   */
  var frameState = event.frameState;
  /** frameState{olx.FrameState}
   * The frame state at the time of the event.
   * イベント時のフレーム状態。
   * (ol3 API[説明は Stable Only のチェックを外すと表示])
   */
  var flashGeom = feature.getGeometry().clone();
  /** getGeometry()
   * Returns the Geometry associated with this feature 
   * using the current geometry name property. By default, 
   * this is geometry but it may be changed by calling 
   * setGeometryName.
   * 現在のジオメトリネームプロパティを使用して、このフィーチャに
   * 関連したジオメトリを返します。デフォルトでは、ジオメトリです
   * が、setGeometryName を呼び出すことによって変更することが
   * できます。(ol3 API)
   */
  /** clone()
   * Clone this feature. If the original feature has 
   * a geometry it is also cloned. The feature id is 
   * not set in the clone.
   * このフィーチャを複製します。元のフィーチャは、ジオメトリ
   * を有する場合にも複製します。フィーチャ ID は、クローンに
   * 設定されていません。(ol3 API)
   */
  var elapsed = frameState.time - start;
  var elapsedRatio = elapsed / duration;
  // radius will be 5 at start and 30 at end.
  var radius = ol.easing.easeOut(elapsedRatio) * 25 + 5;
  /** ol.easing.easeOut(t)
   * Start fast and slow down.
   * 早くしたり遅くしたりします。
   * (ol3 API[説明は Stable Only のチェックを外すと表示])
   */
  var opacity = ol.easing.easeOut(1 - elapsedRatio);
  var flashStyle = new ol.style.Circle({
  /** ol.style.Circle
   * Set circle style for vector features.
   * ベクタフィーチャの円のスタイルを設定。(ol3 API)
   */
   radius: radius,
   snapToPixel: false,
   /** snapToPixel:
    * If true integral numbers of pixels are used as 
    * the X and Y pixel coordinate when drawing the 
    * circle in the output canvas. If false 
    * fractional numbers may be used. Using true 
    * allows for "sharp" rendering (no blur), while 
    * using false allows for "accurate" rendering. 
    * Note that accuracy is important if the 
    * circle's position is animated. Without it, the 
    * circle may jitter noticeably. Default value is 
    * true.
    * true(真)の場合、ピクセルの整数は、出力キャンバスに
    * 円を描画するとき、X と Y のピクセル座標として使用され
    * ます。false(偽)の場合、分数を使用することができます。
    * true(真)を使用すると「シャープ」なレンダリング(ぼ
    * かしなし)を可能にします。一方、false(偽)を使用する
    * と「精密」なレンダリングを可能にします。円の位置がアニ
    * メーション化されている場合は、その精度が重要であること
    * に注意してください。それがなければ、円が著しく小刻みに
    * 動きます。デフォルト値は true です。
    * (ol3 API[説明は Stable Only のチェックを外すと表示])
    */
   stroke: new ol.style.Stroke({
   /** ol.style.Stroke 
    * Set stroke style for vector features. 
    * Note that the defaults given are the Canvas defaults, 
    * which will be used if option is not defined. 
    * The get functions return whatever was entered 
    * in the options;  they will not return the default.
    * ベクタフィーチャのためのストロークスタイルの設定。
    * デフォルトは、オプションが定義されていない場合に使用され
    * る Canvas のデフォルトを与えられることに注意してください。
    * GET関数は、オプションで入力されたものはすべて返します。
    * それらはデフォルトを返しません。(ol3 API)
    */
    color: 'rgba(255, 0, 0, ' + opacity + ')',
    width: 1,
    opacity: opacity
   })
  });
  vectorContext.setImageStyle(flashStyle);
  /** setImageStyle()
   * Set the image style for subsequent draw 
   * operations. Pass null to remove the image 
   * style.
   * その後のドロー操作のための画像のスタイルを設定します。
   * 画像のスタイルを削除するには null を渡します。
   * (ol3 API[説明は Stable Only のチェックを外すと表示])
   */
  vectorContext.drawPointGeometry(flashGeom, null);
  /** drawPointGeometry(pointGeometry, feature)
   * Render a Point geometry into the canvas. 
   * Rendering is immediate and uses the current 
   * style.
   * キャンバスにポイントジオメトリをレンダリングします。
   * レンダリングは即座にされ、現在のスタイルを使用します。
   * (ol3 API[説明は Stable Only のチェックを外すと表示])
   */
  if (elapsed > duration) {
   ol.Observable.unByKey(listenerKey);
   /** ol.Observable.unByKey(key)
    * Removes an event listener using the key 
    * returned by on() or once().
    * on() または once() によって返されたキーを使うことで
    * イベントリスナを削除します。(ol3 API)
    */
   return;
  }
  // tell OL3 to continue postcompose animation
  frameState.animate = true;
 }
 listenerKey = map.on('postcompose', animate);
 /** on
  * Listen for a certain type of event.
  * あるタイプのイベントをリッスンします。(ol3 API)
  */
 /** postcompose イベント
  * レイヤを描画した後に発生するイベント。
  * (「Layer spy example」参照)
  */
}
source.on('addfeature', function(e) {
 flash(e.feature);
});
window.setInterval(addRandomFeature, 1000);
/** WindowTimers.setInterval()
 * Calls a function or executes a code snippet 
 * repeatedly, with a fixed time delay between 
 * each call to that function. Returns an 
 * intervalID.
 * 関数を呼び出すか、その関数への各呼び出しの間に一定の時間
 * 遅延して、繰り返しコードスニペットを実行します。 
 * intervalID を返します。
 * (MDN[https://developer.mozilla.org/en-US/
 * docs/Web/API/WindowTimers/setInterval])
 */


2 - ol3.7ex 123a - Feature animation example 1

「Feature animation example (feature-animation.html)」を参考に地図を表示してみます。
説明に次のようにあります。

This example shows how to use postcompose and vectorContext to animate features. Here we choose to do a flash animation each time a feature is added to the layer.
この例では、フィーチャをアニメーションする postcompose と vectorContext を使用する方法を示します。ここでは、フィーチャがレイヤに追加されるたびにフラッシュアニメーションを実行することを選択します。


HTML ファイルの作成
a Eclipse のメニューの「ファイル」->「ファイルを開く」をクリックします。





b 「ファイルを開く」ウィンドウで、「user」->「mapsite」->「ol3proj」->「v3.7.0」->「examples」->「feature-animation.html」をクリックして選択し、「OK」ボタンをクリックします。
同じように「feature-animation.js」を開きます。





c メニューの「ファイル」->「新規」 -> 「ファイル」をクリックします。



d 「ファイル」ウィンドウで「ol3proj」をクリックして選択し、「ファイル名」を「2123-ol3ex.html」と入力し、「次へ」ボタンをクリックします。








e 「File Template」ウィンドウで「HTML 5 Template」をクリックして選択し、「OK」ボタンをクリックします。











f 「feature-animation.html」の内容をコピーして「2123-ol3ex.html」に貼り付け、修正します。
g 同じように、新規に「2123-ol3ex.js」ファイルを作成し、「File Template」ウィンドウで「JavaScript Template」をクリックして選択し、「完了」ボタンをクリックして、「feature-animation.js」の内容をコピーして貼り付け、修正します。「feature-animation-require.js」も「2123-ol3ex-require.js」に貼り付けます。

「2123-ol3ex.html」
<!doctype html>
<html lang="en">
 <head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="chrome=1">
  <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-combined.min.css" type="text/css">
  <!--
  <link rel="stylesheet" href="../css/ol.css" type="text/css">
  <link rel="stylesheet" href="./resources/layout.css" type="text/css">

  <link rel="stylesheet" href="./resources/prism/prism.css" type="text/css">
  <script src="./resources/zeroclipboard/ZeroClipboard.min.js"></script>
  「resources」の位置が変わりました。
  -->
  <!-- ディレクトリ修正 -->
  <link rel="stylesheet" href="v3.7.0/css/ol.css" type="text/css">
  <link rel="stylesheet" href="v3.7.0/examples/resources/layout.css" type="text/css">

  <link rel="stylesheet" href="v3.7.0/examples/resources/prism/prism.css" type="text/css">
  <script src="v3.7.0/examples/resources/zeroclipboard/ZeroClipboard.min.js"></script>
  <title>Feature animation example</title>
 </head>
 <body>
  <!-- 
  bootstrap-combined.min.css, ol.css, layout.css,
  CSSファイルで設定されたセレクタを使用。
  -->
  <header class="navbar" role="navigation">
   <div class="container" id="navbar-inner-container">
    <!--
    <a class="navbar-brand" href="./"><img src="./resources/logo-70x70.png"> OpenLayers 3 Examples</a>
    -->
    <!-- ディレクトリ修正 -->
    <a class="navbar-brand" href="v3.7.0/examples/"><img src="v3.7.0/examples/resources/logo-70x70.png"> OpenLayers 3 Examples</a>
   </div>
  </header>
  <div class="container-fluid">
   <div class="row">
    <div class="span8">
     <div id="map" class="map"></div>
    </div>
   </div>
   <div class="row-fluid">
    <div class="span12">
     <h4 id="title">Feature animation example</h4>
     <p id="shortdesc">Demonstrates how to animate 
      features. </p>
     <div id="docs">
      <p>This example shows how to use 
       <b>postcompose</b> and <b>vectorContext</b> 
       to animate features. Here we choose to do 
       a flash animation each time a feature is 
       added to the layer.</p>
     </div>
     <div id="tags">animation, vector, feature, flash
     </div>
     <div id="api-links">Related API documentation: 
      <ul class="inline">
       <li>
        <!--<a href="../apidoc/ol.Feature.html" title="API documentation for ol.Feature">ol.Feature>/a> -->
        <a href="v3.7.0/apidoc/ol.Feature.html" title="API documentation for ol.Feature">ol.Feature</a>
       </li>,
       <li>
        <!--<a href="../apidoc/ol.Map.html" title="API documentation for ol.Map">ol.Map>/a> -->
        <a href="v3.7.0/apidoc/ol.Map.html" title="API documentation for ol.Map">ol.Map</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.Observable.html" title="API documentation for ol.Observable">ol.Observable>/a> -->
        <a href="v3.7.0/apidoc/ol.Observable.html" title="API documentation for ol.Observable">ol.Observable</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.View.html" title="API documentation for ol.View">ol.View>/a> -->
        <a href="v3.7.0/apidoc/ol.View.html" title="API documentation for ol.View">ol.View</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.control.html" title="API documentation for ol.control">ol.control>/a> -->
        <a href="v3.7.0/apidoc/ol.control.html" title="API documentation for ol.control">ol.control</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.easing.html" title="API documentation for ol.easing">ol.easing>/a> -->
        <a href="v3.7.0/apidoc/ol.easing.html" title="API documentation for ol.easing">ol.easing</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.geom.Point.html" title="API documentation for ol.geom.Point">ol.geom.Point>/a> -->
        <a href="v3.7.0/apidoc/ol.geom.Point.html" title="API documentation for ol.geom.Point">ol.geom.Point</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.layer.Tile.html" title="API documentation for ol.layer.Tile">ol.layer.Tile>/a> -->
        <a href="v3.7.0/apidoc/ol.layer.Tile.html" title="API documentation for ol.layer.Tile">ol.layer.Tile</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.layer.Vector.html" title="API documentation for ol.layer.Vector">ol.layer.Vector>/a> -->
        <a href="v3.7.0/apidoc/ol.layer.Vector.html" title="API documentation for ol.layer.Vector">ol.layer.Vector</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.proj.html" title="API documentation for ol.proj">ol.proj>/a> -->
        <a href="v3.7.0/apidoc/ol.proj.html" title="API documentation for ol.proj">ol.proj</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.source.OSM.html" title="API documentation for ol.source.OSM">ol.source.OSM>/a> -->
        <a href="v3.7.0/apidoc/ol.source.OSM.html" title="API documentation for ol.source.OSM">ol.source.OSM</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.source.Vector.html" title="API documentation for ol.source.Vector">ol.source.Vector>/a> -->
        <a href="v3.7.0/apidoc/ol.source.Vector.html" title="API documentation for ol.source.Vector">ol.source.Vector</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.style.Circle.html" title="API documentation for ol.style.Circle">ol.style.Circle</a> -->
        <a href="v3.7.0/apidoc/ol.style.Circle.html" title="API documentation for ol.style.Circle">ol.style.Circle</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.style.Stroke.html" title="API documentation for ol.style.Stroke">ol.style.Stroke</a> -->
        <a href="v3.7.0/apidoc/ol.style.Stroke.html" title="API documentation for ol.style.Stroke">ol.style.Stroke</a>
       </li>
      </ui>
     </div>
   </div>
  </div>
  <div class="row-fluid">
   <hr>
   <form method="POST" target="_blank" action="http://jsfiddle.net/api/post/jquery/1.11.0/">
    <input type="button" class="btn btn-info" id="copy-button" value="Copy example code">
    <input type="submit" class="btn btn-primary" id="jsfiddle-button" value="Create JSFiddle">
    <textarea class="hidden" name="js">
// --- 省略 ---
&lt;/html&gt;</code></pre>
    </div>
   </div>
  </div>
  <script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
  <!--
  <script src="./resources/common.js"></script>
  <script src="./resources/prism/prism.min.js"></script>
  -->
  <!-- ディレクトリ修正
   CommonJS と
   prism.js
 -->
  <script src="v3.7.0/examples/resources/common.js"></script>
  <script src="v3.7.0/examples/resources/prism/prism.min.js"></script>
  <!-- 
  <script src="loader.js?id=feature-animation"></script>
  -->
  <!-- ファイル修正 -->  <!-- ディレクトリ修正 -->
  <script src="loader.js?id=2123-ol3ex"></script>
  </body>
</html>


COMMONJS は

COMMONJS
http://webpack.github.io/docs/commonjs.html

に、次のようにあります。

The CommonJS group defined a module format to solve JavaScript scope issues by making sure each module is executed in its own namespace.
This is achieved by forcing modules to explicitly export those variables it wants to expose to the “universe”, and also by defining those other modules required to properly work.
To achieve this CommonJS give you two tools:
the require() function, which allows to import a given module into the current scope.
the module object, which allows to export something from the current scope.

CommonJSグループは、それ自身の名前空間内で実行されている各モジュールを確認することによって、JavaScriptのスコープ問題を解決するためのモジュールフォーマットを定義しました。
これは、それが「universe(?)」に公開したい変数を明示的にエクスポートするモジュールを強制することによって、同じように、正常に動作するのに必要な他のモジュールを定義することによって、達成されます。
この CommonJS を達成するために2つのツールを与えます:
require()関数、指定したモジュールを現在のスコープにインポートすることができます。
モジュールオブジェクト、現在のスコープからエクスポートすることができます。


Prism は、

Prism
http://prismjs.com/

に、次のようにあります。

Prism is a lightweight, extensible syntax highlighter, built with modern web standards in mind. It’s a spin-off from Dabblet and is tested there daily by thousands.
Prismは、最新のWeb標準に構築されたことを考慮し軽量で拡張可能なシンタックスハイライトです。それは Dabblet からスピンオフで、何千人も日々そこで試験されています。


ZeroClipboard は

ZeroClipboard v2.x
http://zeroclipboard.org/

に、次のようにあります。

The ZeroClipboard library provides an easy way to copy text to the clipboard using an invisible Adobe Flash movie and a JavaScript interface.
ZeroClipboard ライブラリは、見えない Adobe Flash ムービーとJavaScript のインターフェイスを使用してテキストをクリップボードにコピーする簡単な方法を提供します。

Debian 8 では動作しませんでした。ボタンを右クリックしたときに flash のコンテキストメニューが表示されると動作しています。

2015年2月22日日曜日

2 - ol3.2ex 68b -Animation example 2

「animation.js(268-ol3ex.js)」は、マップを表示するための JavaScript ファイルです。

「268-ol3ex.js」
// from https://github.com/DmitryBaranovskiy/raphael
function bounce(t) {
 var s = 7.5625, p = 2.75, l;
 if (t < (1 / p)) {
  l = s * t * t;
 } else {
  if (t < (2 / p)) {
   t -= (1.5 / p);
   l = s * t * t + 0.75;
  } else {
   if (t < (2.5 / p)) {
    t -= (2.25 / p);
    l = s * t * t + 0.9375;
   } else {
    t -= (2.625 / p);
    l = s * t * t + 0.984375;
   }
  }
 }
 return l;
}
// from https://github.com/DmitryBaranovskiy/raphael
function elastic(t) {
 return Math.pow(2, -10 * t) * Math.sin((t - 0.075) * (2 * Math.PI) / 0.3) + 1;
 /** Math.pow(base, exponent)
  * base を exponent 乗した値、つまり、base^exponent の値を返
  * します。
  * (MDN[https://developer.mozilla.org/ja/docs/Web/
  * JavaScript/Reference/Global_Objects/Math/pow])
  */
 /** Math.sin()
  * 引数として与えた数のサイン(正弦)を返します。
  * (MDN[https://developer.mozilla.org/ja/docs/Web/
  * JavaScript/Reference/Global_Objects/Math/sin])
  */
  /** Math.PI()
   * 円周率。約 3.14159 です。
   * (MDN[https://developer.mozilla.org/ja/docs/Web
   * /JavaScript/Reference/Global_Objects/Math/PI])
   */
}
var london = ol.proj.transform([-0.12755, 51.507222], 'EPSG:4326', 'EPSG:3857');
/** ol.proj.transform(coordinate, source, destination)
 * Transforms a coordinate from source projection to 
 * destination projection. This returns a new coordinate 
 * (and does not modify the original).
 * ソース投影から変換先投影に座標変換します。これは、新しい座標
 * を返します(オリジナルを変更しません)。(ol3 API)
 */
var moscow = ol.proj.transform([37.6178, 55.7517], 'EPSG:4326', 'EPSG:3857');
var istanbul = ol.proj.transform([28.9744, 41.0128], 'EPSG:4326', 'EPSG:3857');
var rome = ol.proj.transform([12.5, 41.9], 'EPSG:4326', 'EPSG:3857');
var bern = ol.proj.transform([7.4458, 46.95], 'EPSG:4326', 'EPSG:3857');
var madrid = ol.proj.transform([-3.683333, 40.4], 'EPSG:4326', 'EPSG:3857');
var view = new ol.View({
 // the view's initial state
 center: istanbul,
 zoom: 6
});
var map = new ol.Map({
 layers: [
  new ol.layer.Tile({
  /** ol.layer.Tile 
   * For layer sources that provide pre-rendered, tiled 
   * images in grids that are organized by zoom levels for 
   * specific resolutions. 
   * プリレンダリング(事前描画)を提供するレイヤソースのための、
   * 特定の解像度でのズームレベルによって編成されているグリッドの
   * タイルイメージ。(ol3 API)
   */
   preload: 4,
   /** preload:
    * Preload. Load low-resolution tiles up to 
    * preload levels. By default preload is 0, 
    * which means no preloading.
    * プリロード。プリロードレベルに至るまで低解像度の
    * タイルをロードします。デフォルトはプリロード 0 で、
    * プレロードがないことを意味します。(ol3 API)
    */
   source: new ol.source.OSM()
   /** ol.source.OSM 
    * Layer source for the OpenStreetMap tile server.
    * OpenStreetMap タイルサーバのレイヤソース。(ol3 API)
    */
  })
 ],
 renderer: exampleNS.getRendererFromQueryString(),
 /** 'example-behavior.js' により URL にある renderer を返します */
 /** Improve user experience by loading tiles while 
  * animating. Will make animations stutter on mobile 
  * or slow devices.
  * アニメーション化しながらタイルをロードすることによりユーザ
  * エクスペリエンスを向上させます。アニメーションは、モバイル
  * または低速デバイス上で途切れ途切れになります。
  */
 loadTilesWhileAnimating: true,
 /** loadTilesWhileAnimating:
  * When set to true, tiles will be loaded during 
  * animations. This may improve the user experience, 
  * but can also make animations stutter on devices 
  * with slow memory. Default is `false`.
  * true に設定すると、タイルは、アニメーションの間にに
  * ロードされます。これは、ユーザーエクスペリエンスを向
  * 上させることだけでなく、アニメーションが遅いメモリを
  * 搭載したデバイス上で途切れ途切れにすることができます。
  * デフォルトは `false` です。(ol3/extents/olx)
  */
 target: 'map',
 controls: ol.control.defaults({
 /** controls
  * Controls initially added to the map. 
  * If not specified, ol.control.defaults() is used.
  * 初期設定で、マップに追加されたコントロール。
  * 明示されていなければ、ol.control.defaults() が使用されます。
  * (ol3 API)
  */
 /** ol.control.defaults()
  * デフォルトでは、マップに含まコントロールのセット。
  * 特に設定しない限り、これは、以下の各コントロールの
  * インスタンスを含むコレクションを返します。(ol3 API)
  * ol.control.Zoom, ol.control.Rotate, ol.control.Attribution
  */
  attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
  /** @type 
   * 値のタイプ(型)の説明 - 式などで表示
   * (@use JSDoc[http://usejsdoc.org/]より)
   */
   collapsible: false // 折りたたみ
  })
 }),
 view: view
});
var rotateLeft = document.getElementById('rotate-left');
rotateLeft.addEventListener('click', function() {
/** EventTarget.addEventListener
 * addEventListener は、 1 つのイベントターゲットにイベント 
 * リスナーを1 つ登録します。イベントターゲットは、ドキュメント
 * 上の単一のノード、ドキュメント自身、ウィンドウ、あるいは、
 * XMLHttpRequest です。
 *(MDN[https://developer.mozilla.org/ja/docs/Web/API/
 * EventTarget.addEventListener])
 */
 var rotateLeft = ol.animation.rotate({
 /** ol.animation
  * The animation static methods are designed to be 
  * used with the ol.Map#beforeRender method. 
  * アニメーション静的メソッドは ol.Map#beforeRender
  * メソッドで使用するように設計されています。(使用例は
  * ol3 API を参照してください。メソッドについては
  * 「Stable Only」のチェックを外すと表示されます。 )
  */
  duration: 2000,
  /** duration:
   * The duration of the animation in milliseconds. 
   * Default is 1000.
   * ミリ秒単位のアニメーションの継続時間。デフォルトは、1000。
   * (ol3 API[説明は Stable Only のチェックを外すと表示])
   */
  rotation: -4 * Math.PI
  /** rotation:
   * The rotation value (in radians) to begin 
   * rotating from, typically 
   * map.getView().getRotation(). 
   * If undefined then 0 is assumed.
   * 一般的に、 map.getView()。getRotation()から
   * 回転を開始しする(ラジアン)回転値。定義されていなけ
   * れば、0 が仮定されています。
   * (ol3 API[説明は Stable Only のチェックを外すと表示])
   */
  /** Math.PI
   * 円周率。約 3.14159 です。
   * (MDN[https://developer.mozilla.org/ja/docs/Web
   * /JavaScript/Reference/Global_Objects/Math/PI])
   */
 });
 map.beforeRender(rotateLeft);
 /** beforeRender()
  * Add functions to be called before rendering. 
  * This can be used for attaching animations before 
  * updating the map's view. The ol.animation 
  * namespace provides several static methods for 
  * creating prerender functions.
  * レンダリングの前に呼び出される関数を追加します。これは、
  * マップのビューを更新する前にアニメーションを取り付ける
  * ために使用することができます。 ol.animation名前空間は、
  * 事前レンダリング機能を作成するためのいくつかの静的メソッ
  * ドを提供します。
  * (ol3 API[説明は Stable Only のチェックを外すと表示])
  */
}, false);
var rotateRight = document.getElementById('rotate-right');
rotateRight.addEventListener('click', function() {
 var rotateRight = ol.animation.rotate({
  duration: 2000,
  rotation: 4 * Math.PI
 });
 map.beforeRender(rotateRight);
}, false);
var rotateAroundRome = document.getElementById('rotate-around-rome');
rotateAroundRome.addEventListener('click', function() {
 var currentRotation = view.getRotation();
 /** getRotation()
  * Returns: The rotation of the view.(ol3 API)
  */
 var rotateAroundRome = ol.animation.rotate({
  anchor: rome,
  /** anchor:
   * The rotation center/anchor. The map rotates 
   * around the center of the view if unspecified.
   * 回転の中心/アンカー。マップが指定されていない場合、
   * ビューの中央を中心に回転します。
   * (ol3 API[説明は Stable Only のチェックを外すと表示])
   */
  duration: 1000,
  rotation: currentRotation
 });
 map.beforeRender(rotateAroundRome);
 view.rotate(currentRotation + (Math.PI / 2), rome);
}, false);
var panToLondon = document.getElementById('pan-to-london');
panToLondon.addEventListener('click', function() {
 var pan = ol.animation.pan({
  duration: 2000,
  source: /** @type {ol.Coordinate} */ (view.getCenter())
  /** source:
   * The location to start panning from, typically 
   * map.getView().getCenter().
   * 一般的に、 map.getView()。getCenter()から
   * 移動を開始しする位置。
   * (ol3 API[説明は Stable Only のチェックを外すと表示])
   */
  /** @type 
   * 値のタイプ(型)の説明 - 式などで表示
   * (@use JSDoc[http://usejsdoc.org/]より)
   */
  /** getCenter()
   * Return: The center of the view.(ol3 API)
   */
 });
 map.beforeRender(pan);
 view.setCenter(london);
 /** setCenter()
  * Set the center of the current view.
  * 現在のビューの中心を設定します。(ol3 API)
  */
}, false);
var elasticToMoscow = document.getElementById('elastic-to-moscow');
elasticToMoscow.addEventListener('click', function() {
 var pan = ol.animation.pan({
  duration: 2000,
  easing: elastic,
  /** easing:
   * The easing function to use. Can be an ol.
   * easing or a custom function. Default is 
   * ol.easing.inAndOut.
   * 使用するためのイージング関数。 ol.easing またはカス
   * タム関数とすることができる。デフォルトは
   * ol.easing.inAndOut です。
   * (ol3 API[説明は Stable Only のチェックを外すと表示])
   */
  source: /** @type {ol.Coordinate} */ (view.getCenter())
 });
 map.beforeRender(pan);
 view.setCenter(moscow);
}, false);
var bounceToIstanbul = document.getElementById('bounce-to-istanbul');
bounceToIstanbul.addEventListener('click', function() {
 var pan = ol.animation.pan({
  duration: 2000,
  easing: bounce,
  source: /** @type {ol.Coordinate} */ (view.getCenter())
 });
 map.beforeRender(pan);
 view.setCenter(istanbul);
}, false);
var spinToRome = document.getElementById('spin-to-rome');
spinToRome.addEventListener('click', function() {
 var duration = 2000;
 var start = +new Date();
 /** Date
  * 日付や時刻を扱うことが可能な、JavaScript の Date 
  * インスタンスを生成します。
  * (MDN[https://developer.mozilla.org/ja/docs/Web/
  * JavaScript/Reference/Global_Objects/Date])
  */
 var pan = ol.animation.pan({
  duration: duration,
  source: /** @type {ol.Coordinate} */ (view.getCenter()),
  start: start
  /** start:
   * The start time of the animation. Default is 
   * immediately.
   * アニメーションの開始時刻。デフォルトは直後にです。
   * (ol3 API[説明は Stable Only のチェックを外すと表示])
   */
 });
 var rotate = ol.animation.rotate({
  duration: duration,
  rotation: 2 * Math.PI,
  start: start
 });
 map.beforeRender(pan, rotate);
 view.setCenter(rome);
}, false);
var flyToBern = document.getElementById('fly-to-bern');
flyToBern.addEventListener('click', function() {
 var duration = 2000;
 var start = +new Date();
 var pan = ol.animation.pan({
  duration: duration,
  source: /** @type {ol.Coordinate} */ (view.getCenter()),
  start: start
 });
 var bounce = ol.animation.bounce({
  duration: duration,
  resolution: 4 * view.getResolution(),
  /** resolution:
   * The resolution to start the bounce from, 
   * typically map.getView().getResolution().
   * 一般的に、 map.getView()。getResolution()から
   * バウンス(跳ねる)を開始しする解像度。
   * (ol3 API[説明は Stable Only のチェックを外すと表示])
   */
  /** getResolution()
   * Return: The resolution of the view.
   * view(ビュー)の解像度を返します。(ol3 API)
   */
  start: start
 });
  map.beforeRender(pan, bounce);
  view.setCenter(bern);
}, false);
var spiralToMadrid = document.getElementById('spiral-to-madrid');
spiralToMadrid.addEventListener('click', function() {
 var duration = 2000;
 var start = +new Date();
 var pan = ol.animation.pan({
  duration: duration,
  source: /** @type {ol.Coordinate} */ (view.getCenter()),
  start: start
 });
 var bounce = ol.animation.bounce({
  duration: duration,
  resolution: 2 * view.getResolution(),
  start: start
  });
 var rotate = ol.animation.rotate({
  duration: duration,
  rotation: -4 * Math.PI,
  start: start
 });
 map.beforeRender(pan, bounce, rotate);
 view.setCenter(madrid);
}, false);