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

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 のコンテキストメニューが表示されると動作しています。

2013年12月11日水曜日

29 - 単純な Vector Feature の描画 3 - ラインとポリゴンの追加

29-4 ライン(線)の表示単純なラインを表示します。vector-features.html では、計算をしてポイントを作成していますが、29-3 で表示したポイントを使用します。

vector-features.html の
「// create a line feature from a list of points」から
「// create a polygon feature from a linear ring of points」の前まで
をコピーして「ol010-nippon_bmi_akiruno_pgis.html」の次の位置に貼り付けます。
---
var point3 = new OpenLayers.Geometry.Point(139.270, 35.724).transform(epsg4326, map.getProjectionObject()); //緯度経度修正
var pointFeature3 = new OpenLayers.Feature.Vector(point3,null,style_mark);
var point4 = new OpenLayers.Geometry.Point(139.270, 35.724).transform(epsg4326, map.getProjectionObject()); //緯度経度修正
var pointFeature4 = new OpenLayers.Feature.Vector(point4,null);
// create a line feature from a list of points
var pointList = [point, point2, point3];
/*
  var newPoint = point;
  for(var p=0; p<15; ++p) {
   newPoint = new OpenLayers.Geometry.Point(newPoint.x + Math.random(1),
                                            newPoint.y + Math.random(1));
   pointList.push(newPoint);
  }
*/
var lineFeature = new OpenLayers.Feature.Vector(
 new OpenLayers.Geometry.LineString(pointList),null,style_green);
map.addLayer(vectorLayer);
// map.setCenter(new OpenLayers.LonLat(point.x, point.y), 5);
vectorLayer.addFeatures([pointFeature, pointFeature3, pointFeature2, pointFeature4, lineFeature]); //, polygonFeature]);
---











29-5 ポリゴン(面)の表示
単純なポリゴンを表示します。vector-features.html では、計算をしてポイントを作成していますが、29-3 で表示したポイントを使用します。

vector-features.html の
「// create a polygon feature from a linear ring of points」から
「map.addLayer(vectorLayer);」の前まで
をコピーして「ol010-nippon_bmi_akiruno_pgis.html」の次の位置に貼り付けます。
---
var lineFeature = new OpenLayers.Feature.Vector(
 new OpenLayers.Geometry.LineString(pointList),null,style_green);
// create a polygon feature from a linear ring of points
/*
 var pointList = [];
  for(var p=0; p<6; ++p) {
  var a = p * (2 * Math.PI) / 7;
  var r = Math.random(1) + 1;
  var newPoint = new OpenLayers.Geometry.Point(point.x + (r * Math.cos(a)),
                                               point.y + (r * Math.sin(a)));
  pointList.push(newPoint);
 }
*/
pointList.push(pointList[0]);
var linearRing = new OpenLayers.Geometry.LinearRing(pointList);
var polygonFeature = new OpenLayers.Feature.Vector(
 new OpenLayers.Geometry.Polygon([linearRing]));
map.addLayer(vectorLayer);
// map.setCenter(new OpenLayers.LonLat(point.x, point.y), 5);
vectorLayer.addFeatures([pointFeature, pointFeature3, pointFeature2, pointFeature4, lineFeature, polygonFeature]);
---



29 - 単純な Vector Feature の描画 2 - ポイントの追加

29-3 ポイント(点)の表示
example フォルダにある「OpenLayers: Vector Features(vector-features.html)」を参考にポイント(point: 点)、ライン(line: 線)、ポリゴン(polygon: 面)を表示します。
最初に、単純なポイントを表示します。
HTML ファイルを準備します。

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







b 「ファイルを開く」ウィンドウで、「OpenLayers-2.13.1」->「ol009-nippon_bmi_akiruno_pgis.html」をクリックして選択し、「OK」ボタンをクリックします。





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




d 「ウィザードを選択」ウィンドウで、「Web」(複数あるときは展開して探してください。)->「HTMLファイル」をクリックして選択し、「次へ」ボタンをクリックします。






e 「HTML」ウィンドウで「openlayersTokyoproj」をクリックして選択し、「ファイル名」を「ol010-nippon_bmi_akiruno_pgis.html」と入力し、「完了」ボタンをクリックします。







f 「ol009-nippon_bmi_akiruno_pgis.html」の内容をコピーして「ol010-nippon_bmi_akiruno_pgis.html」ファイルに貼り付けます。

g メニューの「ファイル」->「開く」をクリックします。







h 「ファイルを開く」ウィンドウで、「OpenLayers-2.13.1」->「examples」->「vector-features.html」をクリックして選択し、「OK」ボタンをクリックします。






i 「vector-features.html」のjavascript の一部をコピーして「ol010-nippon_bmi_akiruno_pgis.html」に貼り付けて、次のように修正します。
(29-2 で追加したところは削除します。)

---
map.addLayers([layer0, layer3, layer1, layer2, layer4]);

// ここから追加
// allow testing of specific renderers via "?renderer=Canvas", etc
var renderer = OpenLayers.Util.getParameters(window.location.href).renderer;
renderer = (renderer) ? [renderer] : OpenLayers.Layer.Vector.prototype.renderers;
/*
 * Layer style
 */
// we want opaque external graphics and non-opaque internal graphics
// 不透明外部図形と不透明でない内部画像を用意
var layer_style = OpenLayers.Util.extend({}, OpenLayers.Feature.Vector.style['default']);
layer_style.fillOpacity = 0.2; // 塗りつぶし透過度
layer_style.graphicOpacity = 1; // 図形透過度
/*
 * Blue style
 */
var style_blue = OpenLayers.Util.extend({}, layer_style);
style_blue.strokeColor = "blue"; // 外周線色
style_blue.fillColor = "blue"; // 塗りつぶし色
style_blue.graphicName = "star"; // 形状
style_blue.pointRadius = 10; // 半径
style_blue.strokeWidth = 3; // 外周線太さ
style_blue.rotation = 45; // 傾き
style_blue.strokeLinecap = "butt"; // 外周線終端タイプ(平坦)
/*
 * Green style
 */
var style_green = {
 strokeColor: "#00FF00", // 16進法の色指定
 strokeWidth: 3,
 strokeDashstyle: "dashdot", // 外周線種類
 pointRadius: 6,
 pointerEvents: "visiblePainted",
/*
 * pointer-events: ポインタイベントの標的要素になれるフィーチャの状況
 * "visiblePainted": fill と stroke が none に設定されていない
 *「対話性 SVG 1.1(第2版)」(http://www.hcn.zaq.ne.jp/___/SVG11-2nd/interact.html)より
 * ポインタがフィーチャに重ねられると次の title: の内容が表示される。
 */
 title: "this is a green line"
};
/*
 * Mark style
 */
var style_mark = OpenLayers.Util.extend({}, OpenLayers.Feature.Vector.style['default']);
/*
 * each of the three lines below means the same, if only one of
 * them is active: the image will have a size of 24px, and the
 * aspect ratio will be kept
 * 下の3本のコードはそれぞれ同じ意味です。その中の一つのコメントを外したとき、
 * 画像サイズは24ピクセルで、アスペクト比(長辺と短辺の比)は保持されます。
 */
// style_mark.pointRadius = 12;
// style_mark.graphicHeight = 24; 
// style_mark.graphicWidth = 24;
/*
 * if graphicWidth and graphicHeight are both set, the aspect ratio
 * of the image will be ignored
 * graphicWidth と graphicHeight が両方設定されていたら、画像のアクセプト比は
 * 無視されます。
 */
style_mark.graphicWidth = 24;
style_mark.graphicHeight = 20;
style_mark.graphicXOffset = 10; // default is -(style_mark.graphicWidth/2);
// x軸方向右に10ピクセル移動
style_mark.graphicYOffset = -style_mark.graphicHeight;
// y軸方向上に style_mark.graphicHeigh の半分移動
style_mark.externalGraphic = "OpenLayers-2.13.1/img/marker.png"; //パス修正
// title only works in Firefox and Internet Explorer
style_mark.title = "this is a test tooltip";
var vectorLayer = new OpenLayers.Layer.Vector("Simple Geometry", {
 style: layer_style,
 renderers: renderer
});
// create a point feature
var epsg4326 = new OpenLayers.Projection("EPSG:4326"); //追加
var point = new OpenLayers.Geometry.Point(139.191, 35.715).transform(epsg4326, map.getProjectionObject()); //緯度経度変換
var pointFeature = new OpenLayers.Feature.Vector(point,null,style_blue);
// OpenLayers.Feature.Vector("ジオメトリ","属性","スタイル")
var point2 = new OpenLayers.Geometry.Point(139.211, 35.742).transform(epsg4326, map.getProjectionObject()); //緯度経度変換
var pointFeature2 = new OpenLayers.Feature.Vector(point2,null,style_green);
var point3 = new OpenLayers.Geometry.Point(139.270, 35.724).transform(epsg4326, map.getProjectionObject()); //緯度経度変換
var pointFeature3 = new OpenLayers.Feature.Vector(point3,null,style_mark);
var point4 = new OpenLayers.Geometry.Point(139.270, 35.724).transform(epsg4326, map.getProjectionObject()); //Offset の効果確認のため追加
var pointFeature4 = new OpenLayers.Feature.Vector(point4,null,null);
map.addLayer(vectorLayer);
// map.setCenter(new OpenLayers.LonLat(point.x, point.y), 5);
vectorLayer.addFeatures([pointFeature, pointFeature3, pointFeature2, pointFeature4]); //, lineFeature, polygonFeature]);
// 追加はここまで
 
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.addControl(new OpenLayers.Control.MousePosition());
map.zoomToMaxExtent();
---


29 - 単純な Vector Feature の描画 1 - Marker の追加のテスト

29-1 HTMLファイルの準備
「23 - OpenLayers で地図を重ねる 3 - 数値標高モデルの画像の地図を重ねる2」で使用した「ol003-nippon_bmi_akiruno.pgis.html」に単純な Vector Feature を描画します。
最初に、HTML ファイルを準備します。

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







b 「ファイルを開く」ウィンドウで、「OpenLayers-2.13.1」->「ol003-nippon_bmi_akiruno_pgis.html」をクリックして選択し、「OK」ボタンをクリックします。





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




d 「ウィザードを選択」ウィンドウで、「Web」(複数あるときは展開して探してください。)->「HTMLファイル」をクリックして選択し、「次へ」ボタンをクリックします。






e 「HTML」ウィンドウで「openlayersTokyoproj」をクリックして選択し、「ファイル名」を「ol009-nippon_bmi_akiruno_pgis.html」と入力し、「完了」ボタンをクリックします。







f 「ol003-nippon_bmi_akiruno_pgis.html」の内容をコピーして「ol009-nippon_bmi_akiruno_pgis.html」ファイルに貼り付けます。
g javascript の一部を次のように修正します。
---
<script src="OpenLayers-2.13.1/lib/OpenLayers.js"></script>

<!-- Proj4js を読込(ol008-nippon_bmi_akiruno_pgis.html からコピー)
 マウスポジション表示の変換だけなら proj4js.js のみで OK -->
<script src="OpenLayers-2.13.1/lib/proj4js/lib/proj4js.js"></script>
<script src="OpenLayers-2.13.1/lib/proj4js/lib/proj4js-combined.js"></script>
<!-- proj4js-combined.js または proj4js-compressed.js どちらかを使用
<script src="OpenLayers-2.13.1/lib/proj4js/lib/proj4js-compressed.js"></script>
-->
<!-- EPSG2451 の定義ファイルを読込 -->
<script src="OpenLayers-2.13.1/lib/proj4js/lib/defs/EPSG2451.js"></script>

<script type="text/javascript">
 var map, layer0, layer1, layer2, layer3, layer4;
---


29-2  マーカの設定
OpenLayers の Documentation Getting Started の最後の「Adding a Vector Marker to the Map」にあるコードを修正してあきる野市の地図に設定してみます。
---
map.addLayers([layer0, layer3, layer1, layer2, layer4]);

var vectorLayer = new OpenLayers.Layer.Vector("Overlay");
var feature = new OpenLayers.Feature.Vector(
 new OpenLayers.Geometry.Point(139.23, 35.73).transform(epsg4326, map.getProjectionObject()), // EPSG:4326 から EPSG:2451 へ座標変換
 {some:'data'},
 {externalGraphic: 'img/marker.png', graphicHeight: 40, graphicWidth: 40});
vectorLayer.addFeatures(feature);
map.addLayer(vectorLayer);
---










計算されているか確認するために次の内容の test.html を作成して Web ブラウザで表示します。

<!DOCTYPE html>
<html>
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <meta name="apple-mobile-web-app-capable" content="yes">

  <link rel="stylesheet" href="OpenLayers-2.13.1/theme/default/style.css" type="text/css">
  <link rel="stylesheet" href="OpenLayers-2.13.1/examples/style.css" type="text/css">
  <title>WMS Example BMI Akiruno PGIS2</title>
  <script src="OpenLayers-2.13.1/lib/OpenLayers.js"></script>

  <!-- Proj4js を読込(ol008-nippon_bmi_akiruno_pgis.html からコピー) -->
  <script src="OpenLayers-2.13.1/lib/proj4js/lib/proj4js.js"></script>
  <script src="OpenLayers-2.13.1/lib/proj4js/lib/proj4js-combined.js"></script>
  <!--
  <script src="OpenLayers-2.13.1/lib/proj4js/lib/proj4js-compressed.js"></script>
  -->
  <script src="OpenLayers-2.13.1/lib/proj4js/lib/defs/EPSG2451.js"></script>

  <script type="text/javascript">
    var epsg4326 = new OpenLayers.Projection("EPSG:4326");
    var epsg2451 = new OpenLayers.Projection("EPSG:2451");
    
    document.write("Point p [before OpenLayers.Projection.transform] is: " + p + "<br />");
    OpenLayers.Projection.transform(p,epsg4326,epsg2451);
    document.write("Point p [after OpenLayers.Projection.transform] is: " + p + "<br />");
    document.write("proj_src is: " + epsg4326 + "<br />");
    document.write("proj_tgt is: " + epsg2451 + "<br />");
    document.write();    
  </script>

</head>
<body>
</body>
</html>

表示結果
Point p [before OpenLayers.Projection.transform] is: POINT(139.23 35.73)
Point p [after OpenLayers.Projection.transform] is: POINT(-54578.447280558 -29787.44735537442)
proj_src is: EPSG:4326
proj_tgt is: EPSG:2451

2010年11月24日水曜日

GeoExt10 Grid with Feature - フィーチャデータのグリッド表示

Grid Panel configured with a GeoExt.data.FeatureStore

GeoJSONドキュメント(mapserver_tokyo.json)から読み込んだフィーチャを読み込んだ Ext グリッドを表示します。

tokyo_pf_pgis.map の gyoseikai レイヤに東京都の人口を追加して GeoJSON データを作成します。
tokyo_pf_pgis.map をつぎのように修正します。

---
DATA "the_geom from (
SELECT gyoseikai.gid AS gid,
gyoseikai.con AS con,
gyoseikai.cn2 AS cn2,
gyoseikai.aac AS aac,
gyoseikai.the_geom AS the_geom,
population.total AS total,
population.male AS male,
population.female AS female,
population.foreigner AS foreigner
FROM gyoseikai LEFT OUTER JOIN population ON gyoseikai.aac = population.aac
)
AS gyosei_pop USING UNIQUE gid USING SRID=-1"
---

次に gyoseikai レイヤの WFS データを出力します。
(データ量が多いので23区だけ出力します。)

///// 参考 /////
MapServer の WFS Filter Encoding サイト
http://mapserver.org/ogc/filter_encoding.html

の検索文字列のフィルタの例より次のコマンドを実行しました。

$ wget -O mapserver_gyoseikai.xml "http://localhost/cgi-bin/mapserv?map=/home/nob61/mapfile/tokyo_pf_pgis.map&request=GetFeature&VERSION=1.0.0&SERVICE=WFS&TYPENAME=gyoseikai&Filter=<Filter><PropertyIsLessThan><PropertyName>aac</PropertyName><Literal>13124</Literal></PropertyIsLessThan></Filter>"

prepare_database(): Query error. Error declaring cursor: ERROR: operator does not exist: character varying < integer
LINE 13: AS gyosei_pop WHERE ( (aac< 13124) ) and (the_geom && setS...
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.

aac の型が文字列になっているのでエラーになったと思われます。

$ wget -O mapserver_gyoseikai.xml "http://localhost/cgi-bin/mapserv?map=/home/nob61/mapfile/tokyo_pf_pgis.map&request=GetFeature&VERSION=1.0.0&SERVICE=WFS&TYPENAME=gyoseikai&Filter=<Filter><PropertyIsLike wildcard='*' singleChar='.' escape='!'><PropertyName>con</PropertyName><Literal>*区</Literal></PropertyIsLike></Filter>"
bash: !: event not found

と表示されます。

How does one escape special characters when writing SQL queries? サイトに
http://www.orafaq.com/faq/how_does_one_escape_special_characters_when_writing_sql_queries

SQL クエリのエスケープキャラクタが "_" であるとあります。
これで23区のデータが出力されました。
///// ここまで /////

今回は範囲を限定して出力しました。

$ wget -O mapserver_gyoseikai.xml "http://localhost/cgi-bin/mapserv?map=/home/nob61/mapfile/tokyo_pf_pgis.map&request=GetFeature&VERSION=1.0.0&SERVICE=WFS&TYPENAME=gyoseikai&bbox=139.62,35.53,139.90,35.80"

出力したデータを GeoJSON データに変換します。

$ ogr2ogr -f "GeoJSON" mapserver_gyoseikai.json mapserver_gyoseikai.xml

mapserver_gyoseikai.json を Eclipse にインポートします。


Example サイト
http://www.geoext.org/examples.html

「Grid with Feature」リンクをクリックすると Grid Panel configured with a GeoExt.data.FeatureStore が表示されます。
feature-grid.js を参考にします。

説明を意訳すると、GeoJSONドキュメントから読み込んだフィーチャを読み込んだ Ext グリッドを示しています。

JS ファイルを新規作成します。
「openlayersTokyoproj」 を右クリックして 新規 -> JavaScript ファイル をクリック。
「JavaScript ファイル」ウィンドウの「ファイル名(任意:feature-grid.js)」に入力して「完了」ボタンをクリック。

var mapPanel, store, gridPanel, mainPanel;

Ext.onReady(function() {
// create map instance
// var map = new OpenLayers.Map();
// 東京都マップ表示
var map = new OpenLayers.Map('map', {
controls: [
new OpenLayers.Control.PanZoom(),
new OpenLayers.Control.LayerSwitcher(),
new OpenLayers.Control.MousePosition(),
new OpenLayers.Control.ScaleLine()
],
projection: new OpenLayers.Projection("EPSG:2456"),
maxResolution: 'auto',
maxExtent: new OpenLayers.Bounds(-279000,1054000,-185000,1104000),
units: 'meters',
displayProjection: new OpenLayers.Projection("EPSG:4326")
});


/*
var wmsLayer = new OpenLayers.Layer.WMS(
"vmap0",
"http://vmap0.tiles.osgeo.org/wms/vmap0",
{layers: 'basic'}
);
*/
var layer1 = new OpenLayers.Layer.WMS( "Tokyo Height WMS",
"http://192.168.1.6/cgi-bin/mapserv?",
{
map: '/home/nob61/mapfile/tokyo_bmi_pgis_img2.map',
layers: 'height',
format: 'image/png'
});
var layer2 = new OpenLayers.Layer.WMS( "Tokyo Kukaku Sen WMS",
"http://192.168.1.6/cgi-bin/mapserv?",
{
map: '/home/nob61/mapfile/tokyo_bmi_pgis_img2.map',
layers: 'kukaku',
transparent: true,
format: 'image/png'
});


// create vector layer
var vecLayer = new OpenLayers.Layer.Vector("vector");
map.addLayers([layer1, layer2, vecLayer]);


// create map panel
mapPanel = new GeoExt.MapPanel({
title: "Map",
region: "center",
height: 400,
width: 600,
map: map,
// center: new OpenLayers.LonLat(5, 45),
// zoom: 6
});


// create feature store, binding it to the vector layer
store = new GeoExt.data.FeatureStore({
layer: vecLayer,
fields: [
// {name: 'name', type: 'string'},
// {name: 'elevation', type: 'float'}
{name: 'con', type: 'string'}, // 郡、区名
{name: 'cn2', type: 'string'}, // 市町村名
{name: 'total', type: 'float'} // 人口
],
proxy: new GeoExt.data.ProtocolProxy({
protocol: new OpenLayers.Protocol.HTTP({
// url: "data/summits.json",
url: "./mapserver_gyoseikai.json", // gyoseikai JSON ファイル
format: new OpenLayers.Format.GeoJSON(
{
'internalProjection': new OpenLayers.Projection("EPSG:2456"),
'externalProjection': new OpenLayers.Projection("EPSG:4326")
}
)
}),
}),
autoLoad: true
});


// create grid panel configured with feature store
gridPanel = new Ext.grid.GridPanel({
title: "Feature Grid",
region: "east",
store: store,
width: 320,
columns: [{
// header: "Name",
header: "区、郡",
// width: 200,
width: 100,
// dataIndex: "name"
dataIndex: "con",
sortable: true
},{
// header: "Elevation",
header: "市町村",
width: 100,
// dataIndex: "elevation"
dataIndex: "cn2"
},{ // ここから「人口」を追加
header: "人口",
width: 100,
dataIndex: "total"
}],
sm: new GeoExt.grid.FeatureSelectionModel()
});


// create a panel and add the map panel and grid panel
// inside it
mainPanel = new Ext.Panel({
renderTo: "mainpanel",
layout: "border",
height: 400,
width: 920,
items: [mapPanel, gridPanel]
});
});

HTML ファイルを新規作成します。
「openlayersTokyoproj」 を右クリックして 新規 -> HTML ファイル をクリック。
「HTML ファイル」ウィンドウの「ファイル名(任意:geoext10_feature-grid.html)」に入力して「完了」ボタンをクリック。
「charset」を「utf-8」にします。
以前使用した OpenLayers.Layer.WMS レイヤの例を参考に以下のように HTML を作成します。
(geoext08_map-tool.html をコピーし feature-grid.js を追加し body タグ内を修正します。)

---
<title>GeoExt10 Grid with Feature</title>
---
<!-- feature-grid.js 追加 -->
<script type="text/javascript" src="./feature-grid.js"></script>
</head>
<body>
<h1 id="title">GeoExt 10 - Grid with Feature</h1>
<p id="shortdesc">
Grid Panel configured with a GeoExt.data.FeatureStore
</p>
<p>This example shows an Ext grid loaded with features read from
a GeoJSON document (data/summits.json).Because the layer and
the store are bound to each other, the features loaded into the store
are automatically added to the layer. A GeoExt feature selection model
is also used so that selecting rows in the grid selects features in the
layer, and vice-versa.<p>
<p>この例では、GeoJSONドキュメント(data/summits.json)から読み込んだ
フィーチャを読み込んだ Ext グリッドを示しています。レイヤとストアは、お互いに
バインドされているので、フィーチャはレイヤを自動的に追加されたストアにロードします。
GeoExt フィーチャ選択モデルは、レイヤ中のフィーチャを選択するグリッド内の行を
選択するために、もしくはその逆に使用されます。</p>

<div id="mainpanel"></div>

</body>
</html>