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

2018年10月31日水曜日

OpenLayers5 Workshop - 3.2 Interact with VectorTile features

3 Vector Tile
3.2 Interact with VectorTile features
VectorTile フィーチャを使ってインタラクション

If we want to style the layer we just created, it would be nice to get some information about each geometry we see on the map. The nice thing about vector tile layers is that we can interact with them just like with vector layers. So it is easy to add a listener for clicks to the map, query the features at the clicked position, and display a popup with the attributes of each feature.

今、作成されたレイヤをスタイル(装飾)したいなら、マップ上に見える個々のジオメトリについて情報を取得することは良いことです。ベクタタイルレイヤについて良いことは、ベクタレイヤと同じくそれらを情報交換できるということです。マップにクリックリスナを追加することは簡単なので、クリックされた場所のフィーチャに問い合わせ、個々のフィーチャの属性と一緒にポップアップを表示します。

Adding a popup
ポップアップを追加

We create a popup style by going to http://www.cssarrowplease.com/. I decided to choose a darker popup. The css is added to the <style> section of our index.html:

http://www.cssarrowplease.com/ に行ってポップアップを作成します。ここでは、暗いポップアップを選ぶことにしました。css は、index.html の <style> セクションに追加します:
.arrow_box {
 position: relative;
 background: #000;
 border: 1px solid #003c88;
}
.arrow_box:after, .arrow_box:before {
 top: 100%;
 left: 50%;
 border: solid transparent;
 content: " ";
 height: 0;
 width: 0;
 position: absolute;
 pointer-events: none;
}
.arrow_box:after {
 border-color: rgba(0, 0, 0, 0);
 border-top-color: #000;
 border-width: 10px;
 margin-left: -10px;
}
.arrow_box:before {
 border-color: rgba(0, 60, 136, 0);
 border-top-color: #003c88;
 border-width: 11px;
 margin-left: -11px;
}
.arrow_box {
 border-radius: 5px;
 padding: 10px;
 opacity: 0.8;
 background-color: black;
 color: white;
}
We are going to render scrollable HTML tables into our popup, so our markup for the popup also needs a <div> for the popup content:

ポップアップにスクロールできる HTML テーブル(表)を描画するので、ポップアップのためのマークアップにもポップアップコンテンツに <div> が必要です:
<div class="arrow_box" id="popup-container">
 <div id="popup-content"></div>
</div>
To style the tables, we add some more style to the <style> section of index.html:

テーブルをスタイルするために、index.html の <style> セクションにいくつかさらにスタイルを追加します。
#popup-content {
  max-height: 200px;
  overflow: auto;
}
#popup-content th {
  text-align: left;
  width: 125px;
}
In the application's main.js import the Overlay class:

アプリケーションの main.js に Overlay クラスをインポートします:

import Overlay from 'ol/Overlay';

Again in the application's main.js, we can now append the code for the popup's Overlay:

もう一度、アプリケーションの main.js に、ポップアップの Overlay に対するコードを、直ちに、追加できます:

const overlay = new Overlay({
 element: document.getElementById('popup-container'),
 positioning: 'bottom-center',
 offset: [0, -10],
 autoPan: true
});
map.addOverlay(overlay);
To make it easy to close the popup so it does not cover other features we might want to click, we add a click listener to the overlay, so it closes when we click on it:

クリックしたい他のフィーチャを覆わないようにポップアップを閉じるのを簡単にするために、クリックリスナをオーバレイに追加し、それにより、クリックしたときそれが閉じます。
overlay.getElement().addEventListener('click', function() {
 overlay.setPosition();
});
Calling setPosition() on an overlay sets an undefined position, which causes the overlay to disappear.

オーバレイ上の setPosition() を呼び出すことは、定義されていない場所を設定し、オーバレイを消します。

Fill the popup with feature attributes
ポップアップをフィーチャ属性で満たす

Now it is time to connect the popup to a click listener on the map. We append more code at the bottom of main.js:

今、マップ上のポップアップをクリックリスナに接続するときです。main.js の下部にさらに多くのコードを追加します:
map.on('click', function(e) {
 let markup = '';
 map.forEachFeatureAtPixel(e.pixel, function(feature) {
  markup += `${markup && '<hr>'}<table>`;
  const properties = feature.getProperties();
  for (const property in properties) {
   markup += `<tr><th>${property}</th><td>${properties[property]}</td></tr>`;
  }
  markup += '</table>';
 }, {hitTolerance: 1});
 if (markup) {
  document.getElementById('popup-content').innerHTML = markup;
  overlay.setPosition(e.coordinate);
 } else {
  overlay.setPosition();
 }
});
By iterating through all the features we get at the clicked position (map.forEachFeatureAtPixel), we build a separate table for each feature. With each feature, we iterate through its properties (feature.getProperties()), and add a table row (<tr>) for each property. We also set a hitTolerance of 1 pixel to make it easier to click on lines.

すべてのフィーチャに渡って繰り返すことによって、クリックされた位置を取得し(map.forEachFeatureAtPixel)、個々のフィーチャに対する分かれたテーブルを構築します。個々のフィーチャで、そのプロパティに渡って繰り返し(feature.getProperties())、個々のプロパティに対してテーブルロー(列)を追加します。線上をクリックするのを簡単にするために1ピクセルの hitTolerance の設定もします。

Using the interactivity to build a style for our map
インタラクティビティをマップのスタイルを構築するために使う

Now we can click on any geometry in the map, and use the information we get in the popup to create styles in the next exercise. Note that vector tile features have a special layer property, which indicates the source layer (i.e. the layer the feature belongs to in the vector tile's structure, which is a layer -> feature hierarchy).

現在、マップのすべてのジオメトリ上をクリックでき、次の演習でスタイルを作成するためにポップアップで取得する情報を使います。ベクタタイルフィーチャは特別なレイヤプロパティを持ち、それは、ソースレイヤを示します(例えば、フィーチャが所属しているベクタタイル構造のレイヤで、それは レイヤ -> フィーチャヒエラルキです)。

Getting feature information

■□ Debian9 で試します■□
「Interact with VectorTile features」の例を表示します。「The VectorTile layer」で使用した index.html のバックアップを保存して次のように修正します。

user@deb9-vmw:~/openlayers-workshop-en$ cp index.html index.html_vectortile
user@deb9-vmw:~/openlayers-workshop-en$ vim index.html
<!DOCTYPE html>
<html>
 <head>
  <meta charset="utf-8">
  <title>OpenLayers</title>
  <style>
   html, body, #map-container {
    margin: 0;
    height: 100%;
    width: 100%;
    font-family: sans-serif;
   }
   .arrow_box {
    position: relative;
    background: #000;
    border: 1px solid #003c88;
   }
   .arrow_box:after, .arrow_box:before {
    top: 100%;
    left: 50%;
    border: solid transparent;
    content: " ";
    height: 0;
    width: 0;
    position: absolute;
    pointer-events: none;
   }
   .arrow_box:after {
    border-color: rgba(0, 0, 0, 0);
    border-top-color: #000;
    border-width: 10px;
    margin-left: -10px;
   }
   .arrow_box:before {
    border-color: rgba(0, 60, 136, 0);
    border-top-color: #003c88;
    border-width: 11px; 
    margin-left: -11px; 
   } 
   .arrow_box { 
    border-radius: 5px; 
    padding: 10px; 
    opacity: 0.8; 
    background-color: black; 
    color: white; 
   }
   #popup-content { 
    max-height: 200px; 
    overflow: auto; 
   } 
   #popup-content th { 
    text-align: left; 
    width: 125px; 
   }
  </style>
 </head>
 <body>
  <div id="map-container"></div>
  <div class="arrow_box" id="popup-container"> 
   <div id="popup-content"></div>
  </div>
 </body>
</html>
「The VectorTile layer」」で使用した main.js のバックアップを保存して次のように修正します。

user@deb9-vmw:~/openlayers-workshop-en$ cp main.js main.js_vectortile
user@deb9-vmw:~/openlayers-workshop-en$ vim main.js
import 'ol/ol.css';
import Map from 'ol/Map';
import View from 'ol/View';
import MVT from 'ol/format/MVT';
import VectorTileLayer from 'ol/layer/VectorTile';
import VectorTileSource from 'ol/source/VectorTile';
import Overlay from 'ol/Overlay';
// See https://openmaptiles.com/hosting/ for terms and access key
const key = '<your-access-key-here>';
const map = new Map({
 target: 'map-container',
 view: new  View({
  center: [0, 0],
  zoom: 2
 })
});
const layer = new VectorTileLayer({
 source: new VectorTileSource({
  attributions: [
   '<a href="http://www.openmaptiles.org/" target="_blank">&copy; OpenMapTiles</a>',
   '<a href="http://www.openstreetmap.org/about/" target="_blank">&copy; OpenStreetMap contributors</a>'
  ],
  format: new MVT(),
  url: `https://free-{1-3}.tilehosting.com/data/v3/{z}/{x}/{y}.pbf.pict?key=${key}`,
  maxZoom: 14
 })
});
map.addLayer(layer); 
const overlay = new Overlay({
 element: document.getElementById('popup-container'),
 positioning: 'bottom-center',
 offset: [0, -10],
 autoPan: true
});
map.addOverlay(overlay);
overlay.getElement().addEventListener('click', function() {
 overlay.setPosition();
});
map.on('click', function(e) {
 let markup = '';
 map.forEachFeatureAtPixel(e.pixel, function(feature) {
  markup += `${markup && '<hr>'}<table>`;
  const properties = feature.getProperties();
  for (const property in properties) {
   markup += `<tr><th>${property}</th><td>${properties[property]}</td></tr>`;
  }
  markup += '</table>';
 }, {hitTolerance: 1});
 if (markup) {
  document.getElementById('popup-content').innerHTML = markup;
  overlay.setPosition(e.coordinate);
 } else {
  overlay.setPosition();
 }
});
http://localhost:3000/ とブラウザでマップを開きます。(もし開かなければ、'npm start' を実行してください。



2015年9月17日木曜日

2 - ol3.9ex 129b - Custom interaction example 2

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

「2129-ol3ex.js」
/**
 * Define a namespace for the application.
 * アプリケーションのための名前空間の定義。
 */
window.app = {};
var app = window.app;
/**
 * @constructor
 * @extends {ol.interaction.Pointer}
 */
/** 「@constructor(@class と同義)」
 * The @class tag marks a function as being a 
 * constructor, meant to be called with the new 
 * keyword to return an instance.
 * @classタグは、インスタンスを返すために、新しいキーワードで
 * 呼び出されることを意図し、コンストラクタとして function を
 * マークします。
 * (@use JSDoc [http://usejsdoc.org/tags-class.html])
 */
/** 「@extends(@augments と同義)」
 * The @augments or@extends tag indicates that a 
 * symbol inherits from, and potentially adds to, 
 * a parent symbol. You can use this tag to document 
 * both class-based and prototype-based inheritance.
 * @augmentsまたは@@extendsタグは、シンボルが親シンボルから
 * 継承し、潜在的に追加する、ことを示しています。
 * あなたは、クラスベースとプロトタイプベース両方の継承を
 * 文書化するために、このタグを使用することができます。
 * (@use JSDoc [http://usejsdoc.org/tags-augments.html])
 */
app.Drag = function() {
 ol.interaction.Pointer.call(this, {
 /** ol.interaction.Pointer 
  * Base class that calls user-defined functions on 
  * down, move and up events. This class also manages  
  * "drag sequences".
  * When the handleDownEvent user function returns 
  * true a drag sequence is started. During a drag 
  * sequence the handleDragEvent user function is 
  * called on move events. The drag sequence ends 
  * when the handleUpEvent user function is called 
  * and returns false.
  * ダウン(down)、ムーブ(move)、アップ(up)イベント
  * に関するユーザ定義関数を呼び出す基本クラス。このクラス
  * は、「ドラッグ·シーケンス」を管理します。
  * handleDownEvent ユーザ関数が true を返した場合、
  * ドラッグシーケンスが開始されます。ドラッグシーケンスの
  * 間、handleDragEvent ユーザ関数は、ムーブ(move)イ
  * ベントで呼び出されます。ドラッグシーケンスは  
  * handleUpEvent ユーザ関数が呼び出されたときに終了し、
  * false を返します。(ol3 API)
  */
 /** Function.prototype.call()
  * The call() method calls a function with a given 
  * this value and arguments provided individually.
  * call メソッドは、与えられた this 値とここに与えられ
  * た引数とともに、関数を呼び出します。
  * (MDN[https://developer.mozilla.org/en-US/docs/Web/
  * JavaScript/Reference/Global_Objects/Function/call])
  */
  handleDownEvent: app.Drag.prototype.handleDownEvent,
  /** Object.prototype
   * The Object.prototype property represents the 
   * Object prototype object.
   * Object.prototype プロパティは、Object プロパティ
   * オブジェクトを表します。
   * (MDN[https://developer.mozilla.org/en-US/docs/Web/
   * JavaScript/Reference/Global_Objects/Object/prototype])
   */
  handleDragEvent: app.Drag.prototype.handleDragEvent,
  handleMoveEvent: app.Drag.prototype.handleMoveEvent,
  handleUpEvent: app.Drag.prototype.handleUpEvent
 });
 /**
  * @type {ol.Pixel}
  * @private
  */
 /** @type 
  * 値のタイプ(型)の説明 - 式などで表示
  * (@use JSDoc[http://usejsdoc.org/]より)
  */
 /** @private
  * The @private tag marks a symbol as private, or 
  * not meant for general use. Private members are 
  * not shown in the generated output unless JSDoc 
  * is run with the -p/--private command-line 
  * option. In JSDoc 3.3.0 and later, you can also 
  * use the -a/--access command-line option to 
  * change this behavior.
  * @private タグは、プライベートとしての記号を記し、一
  * 般的な使用を意味していません。JSDoc が、-p/--private 
  * command-line オプションと実行されない限り、プライ
  * ベートメンバは生成出力には表示されません。JSDocの3.3.0
  * 以降では、この動作を変更するために -a/--access 
  * command-line オプションを使用することもできます。
  * (@use JSDoc[http://usejsdoc.org/tags-private.html])
  */
 this.coordinate_ = null;
 /**
  * @type {string|undefined}
  * @private
  */
 this.cursor_ = 'pointer';

 /**
  * @type {ol.Feature}
  * @private
  */
 this.feature_ = null;

 /**
  * @type {string|undefined}
  * @private
  */
 this.previousCursor_ = undefined;

};
ol.inherits(app.Drag, ol.interaction.Pointer);
/** ol.inherits(childCtor, parentCtor) 
 * Inherit the prototype methods from one constructor 
 * into another.
 * 1つのコンストラクタから他のひとつにプロトタイプのメソッド
 * を継承します。
 * (ol3 API[説明は Stable Only のチェックを外すと表示])
 */
/**
 * @param {ol.MapBrowserEvent} evt Map browser event.
 * @return {boolean} `true` to start the drag sequence.
 */
/** 「@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])
 */
/** @return(@returns と同義)
 * The @returns tag documents the value that a function 
 * returns.
 * @returns タグは、関数が返す値について説明します。
 * (@use JSDoc [http://usejsdoc.org/tags-returns..html])
 */
app.Drag.prototype.handleDownEvent = function(evt) {
 var map = evt.map;
 var feature = map.forEachFeatureAtPixel(evt.pixel,
 /** forEachFeatureAtPixel(pixel, callback, opt_this, 
  * opt_layerFilter, opt_this2)
  * Detect features that intersect a pixel on the viewport, 
  * and execute a callback with each intersecting feature. 
  * Layers included in the detection can be configured 
  * through opt_layerFilter. 
  * ビューポート上のピクセルと交差するフィーチャを検出し、互
  * いに交差するフィーチャと共にコールバックを実行します。
  * 検出に含まれるレイヤが opt_layerFilter を通じて設定する
  * ことができます。(ol3 API)
  */
  function(feature, layer) {
   return feature;
 });

 if (feature) {
  this.coordinate_ = evt.coordinate;
  this.feature_ = feature;
 }

 return !!feature;
};
/**
 * @param {ol.MapBrowserEvent} evt Map browser event.
 */
app.Drag.prototype.handleDragEvent = function(evt) {
 var map = evt.map;

 var feature = map.forEachFeatureAtPixel(evt.pixel,
  function(feature, layer) {
   return feature;
 });

 var deltaX = evt.coordinate[0] - this.coordinate_[0];
 var deltaY = evt.coordinate[1] - this.coordinate_[1];
 var geometry = /** @type {ol.geom.SimpleGeometry} */
  (this.feature_.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)
  */
 geometry.translate(deltaX, deltaY);
 /** translate(deltaX, deltaY)
  * Translate the geometry.
  * (ol3 API[説明は Stable Only のチェックを外すと表示])
  */
 this.coordinate_[0] = evt.coordinate[0];
 this.coordinate_[1] = evt.coordinate[1];
};
/**
 * @param {ol.MapBrowserEvent} evt Event.
 */
app.Drag.prototype.handleMoveEvent = function(evt) {
 if (this.cursor_) {
  var map = evt.map;
  var feature = map.forEachFeatureAtPixel(evt.pixel,
   function(feature, layer) {
    return feature;
  });
  var element = evt.map.getTargetElement();
  /** getTargetElement
   * Get the DOM element into which this map is rendered. 
   * In contrast to`getTarget` this method always return 
   * an `Element`, or `null` if themap has no target.
   * このマップがレンダリングされる DOM 要素を取得します。
   * マップがターゲットを持っていない場合は、`getTarget`
   * とは対照的に、このメソッドは常に` Element`、もしく
   * は `null`を返します。
   * (ol3 API[説明は Stable Only のチェックを外すと表示])
   */
  if (feature) {
   if (element.style.cursor != this.cursor_) {
    this.previousCursor_ = element.style.cursor;
    element.style.cursor = this.cursor_;
   }
  } else if (this.previousCursor_ !== undefined) {
    element.style.cursor = this.previousCursor_;
    this.previousCursor_ = undefined;
  }
 }
};
/**
 * @param {ol.MapBrowserEvent} evt Map browser event.
 * @return {boolean} `false` to stop the drag sequence.
 */
app.Drag.prototype.handleUpEvent = function(evt) {
 this.coordinate_ = null;
 this.feature_ = null;
 return false;
};
var pointFeature = new ol.Feature(new ol.geom.Point([0, 0]));
/** 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)
 */
/** ol.geom.Point
 * Point geometry.(ol3 API)
 */
var lineFeature = new ol.Feature(
 new ol.geom.LineString([[-1e7, 1e6], [-1e6, 3e6]]));
 /** ol.geom.LineString
  * Linestring geometry.(ol3 API)
  */
var polygonFeature = new ol.Feature(
 new ol.geom.Polygon([[[-3e6, -1e6], [-3e6, 1e6],
  [-1e6, 1e6], [-1e6, -1e6], [-3e6, -1e6]]]));
 /** ol.geom.Polygon
  * Polygon geometry.(ol3 API)
  */
var map = new ol.Map({
 interactions: ol.interaction.defaults().extend([new app.Drag()]),
 /** ol.interaction.defaults
  * Set of interactions included in maps by default. 
  * Specific interactions can be excluded by setting 
  * the appropriate option to false in the constructor 
  * options, but the order of the interactions is fixed. 
  * If you want to specify a different order for 
  * interactions, you will need to create your own 
  * ol.interaction.Interaction instances and insert 
  * them into a ol.Collection in the order you want 
  * before creating your ol.Map instance.
  * デフォルトでマップに含まれるインターラクションのセット。
  * 具体的なインターラクションは、コンストラクタのオプションで適
  * 切なオプションを false に設定することで除外することができま
  * すが、インターラクションの順番は固定されています。インターラ
  * クションに対して別の順番を指定したい場合は、独自の
  * ol.interaction.Interaction インスタンスを作成し、
  * ol.Map インスタンスを作成する前に、望む順番で 
  * ol.Collection にそれらを挿入する必要があります。(ol3 API)
  * new ol.interaction.DragRotateAndZoom()
  *(訳注:インターラクションの順番は、API を参照してください。)
  */
 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.TileJSON({
   /** ol.source.TileJSON 
    * Layer source for tile data in TileJSON format.
    * TileJSON フォーマットのタイルデータのためのレイヤソース。
    *(ol3 API)
    */
    url: 'http://api.tiles.mapbox.com/v3/mapbox.geography-class.jsonp'
   })
  }),
  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.
    * ベクタレイヤのフィーチャのソースを用意します。(ol3 API)
    */
    features: [pointFeature, lineFeature, polygonFeature]
   }),
   style: new ol.style.Style({
   /** ol.style.Style 
    * Base class for vector feature rendering styles.
    * ベクタフィーチャがスタイルを描画するための基本クラス。
    * (ol3 API)
    */
    image: new ol.style.Icon(/** @type {olx.style.IconOptions} */ ({
    /** ol.style.Icon 
     * Set icon style for vector features.
     * ベクタフィーチャのアイコンスタイルを設定します。
     * (ol3 API)
     */
     anchor: [0.5, 46],
     anchorXUnits: 'fraction',
     anchorYUnits: 'pixels',
     opacity: 0.95,
     // src: 'data/icon.png'
     src: 'v3.9.0/examples/data/icon.png'
    })),
    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)
     */
     width: 3,
     color: [255, 0, 0, 1]
    }),
    fill: new ol.style.Fill({
    /** ol.style.Fill 
     * Set fill style for vector features.
     * ベクタフィーチャの塗りつぶしスタイルを設定。(ol3 API)
     */
     color: [0, 0, 255, 0.6]
    })
   })
  })
 ],
 target: 'map',
 view: new ol.View({
  center: [0, 0],
  zoom: 2
 })
});

2 - ol3.9ex 129a - Custom interaction example 1

「Custom interaction example (drag-features.html)」を参考に地図を表示してみます。
(「Drag features example [drag-features.html]」の修正版です。)
説明に次のようにあります。

This example demonstrates using a custom interaction with OpenLayers, by subclassing ol.interaction.Pointer. Note that the built in interaction ol.interaction.Translate might be a better option for moving features.
この例では、ol.interaction.Pointer をサブクラス化することで、OpenLayers でカスタムインタラクションを使用して示しています。組み込まれているインタラクション ol.interaction.Translate は、フィーチャを移動するためのより良い選択肢になることに注意してください。

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





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





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



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








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











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

「2129-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.9.0/css/ol.css" type="text/css">
  <link rel="stylesheet" href="v3.9.0/examples/resources/layout.css" type="text/css">

  <link rel="stylesheet" href="v3.9.0/examples/resources/prism/prism.css" type="text/css">
  <script src="v3.9.0/examples/resources/zeroclipboard/ZeroClipboard.min.js"></script>
  <title>Custom interaction 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.9.0/examples/"><img src="v3.9.0/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">
     <h4 id="title">Custom interaction example</h4>
     <p id="shortdesc">Example of a custom drag features 
     interaction.</p>
     <div id="docs"><p>
      This example demonstrates using a custom interaction 
      with OpenLayers, by subclassing 
      <code>ol.interaction.Pointer</code>. Note that the 
      built in interaction 
      <code>ol.interaction.Translate</code> might be a better 
      option for moving features.</p>
     </div>
     <div id="tags">drag, translate, feature, vector, editing</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.9.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.9.0/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.9.0/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.9.0/apidoc/ol.geom.LineString.html" title="API documentation for ol.geom.LineString">ol.geom.LineString</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.geom.Point.html" title="API documentation for ol.geom.Point">ol.geom.Point>/a> -->
        <a href="v3.9.0/apidoc/ol.geom.Point.html" title="API documentation for ol.geom.Point">ol.geom.Point</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.geom.Polygon.html" title="API documentation for ol.geom.Polygon">ol.geom.Polygon>/a> -->
        <a href="v3.9.0/apidoc/ol.geom.Polygon.html" title="API documentation for ol.geom.Polygon">ol.geom.Polygon</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.interaction.html" title="API documentation for ol.interaction">ol.interaction>/a> -->
        <a href="v3.9.0/apidoc/ol.interaction.html" title="API documentation for ol.interaction">ol.interaction</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.interaction.Pointer.html" title="API documentation for ol.interaction.Pointer">ol.interaction.Pointer>/a> -->
        <a href="v3.9.0/apidoc/ol.interaction.Pointer.html" title="API documentation for ol.interaction.Pointer">ol.interaction.Pointer</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.layer.Tile.html" title="API documentation for ol.layer.Tile">ol.layer.Tile>/a> -->
        <a href="v3.9.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.9.0/apidoc/ol.layer.Vector.html" title="API documentation for ol.layer.Vector">ol.layer.Vector</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.source.TileJSON.html" title="API documentation for ol.source.TileJSON">ol.source.TileJSON>/a> -->
        <a href="v3.9.0/apidoc/ol.source.TileJSON.html" title="API documentation for ol.source.TileJSON">ol.source.TileJSON</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.source.Vector.html" title="API documentation for ol.source.Vector">ol.source.Vector>/a> -->
        <a href="v3.9.0/apidoc/ol.source.Vector.html" title="API documentation for ol.source.Vector">ol.source.Vector</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.style.Fill.html" title="API documentation for ol.style.Fill">ol.style.Fill>/a> -->
        <a href="v3.9.0/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.9.0/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.9.0/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.9.0/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.9.0/examples/resources/common.js"></script>
  <script src="v3.9.0/examples/resources/prism/prism.min.js"></script>
  <!-- 
  <script src="loader.js?id=drag-features"></script>
  -->
  <!-- ファイル修正 -->  <!-- ディレクトリ修正 -->
  <script src="loader.js?id=2129-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 のコンテキストメニューが表示されると動作しています。