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

2015年2月3日火曜日

2 - ol3.1ex 52b - Drag features example 2

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

「252-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.
  * ダウンとムーブ、アップイベントに関するユーザ定義関数を
  * 呼び出す基本クラス。このクラスは、「ドラッグ·シーケン
  * ス」を管理します。
  * handleDownEvent ユーザ関数が true を返した場合、
  * ドラッグシーケンスが開始されます。ドラッグシーケンスの
  * 間、handleDragEvent ユーザ関数は、ムーブイベントで
  * 呼び出されます。ドラッグシーケンスは 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
 * ol.inherits is an alias to the goog.inherits 
 * function. It is exported for use in non-compiled 
 * application code. See ol.exports.
 * ol.inherits は、goog.inherits 関数へのエイリアス
 * です。これは、コンパイルされないアプリケーションコードで
 * 使用するためにエクスポートされます。 ol.exports を参照
 * してください。
 * (penLayers 3 API Documentation - Namespace: ol
 * [http://tschaub.net/openlayers.github.io/en/
 * master/apidoc/ol.html])
 * 
 *  goog.inherits(childCtor, parentCtor) 
 * Inherit the prototype methods from one constructor 
 * into another.
 *  一つのコンストラクタからもうひとつへプロパティメッソドを
 * 継承します。
 * (goog Closure Library API Documentation
 * [http://docs.closure-library.googlecode.com/git/
 * namespace_goog.html])
 */
/**
 * @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
  * 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. Feature overlays will always 
  * be included in the detection.
  * ビューポート上のピクセルと交差するフィーチャを検出し、
  * 各交差するフィーチャとコールバックを実行します。
  * 検出に含まれるレイヤが 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()
    * 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)
    */
  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`を返します。
    * (ol/ol/map.js)
    */
   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)
  *  (訳注:インターラクションの順番は、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.1.1/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.1ex 52a - Drag features example 1

「Drag features example(drag-features.html)」を参考に地図を表示してみます。

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





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





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



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








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











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



「252-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="../css/ol.css" type="text/css">
  <link rel="stylesheet" href="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
  <link rel="stylesheet" href="../resources/layout.css" type="text/css">
  <link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
-->
  <!-- ディレクトリ修正 -->
  <link rel="stylesheet" href="v3.1.1/css/ol.css" type="text/css">
  <link rel="stylesheet" href="v3.1.1/resources/bootstrap/css/bootstrap.min.css" type="text/css">
  <link rel="stylesheet" href="v3.1.1/resources/layout.css" type="text/css">
  <link rel="stylesheet" href="v3.1.1/resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
  <title>Drag features example</title>
 </head>
 <body>
  <!-- 
  bootstrap.min.css, bootstrap-responsive.min.css で設定されたセレクタを使用。
  -->
  <div class="navbar navbar-inverse navbar-fixed-top">
   <div class="navbar-inner">
    <div class="container">
     <!--
     <a class="brand" href="./"><img src="../resources/logo.png"> OpenLayers 3 Examples</a>
     -->
      <!-- ディレクトリ修正 -->
     <a class="brand" href="v3.1.1/examples/"><img src="v3.1.1/resources/logo.png"> OpenLayers 3 Examples</a>
    </div>
   </div>
  </div>
  <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">Drag features example</h4>
     <p id="shortdesc">Example of a drag features interaction.</p>
     <div id="docs">
      <!--
      See the <a href="drag-features.js" target="_blank">drag-features.js source</a> to see how this is done.</p>
      -->
      <!-- ファイル修正 -->
      See the <a href="252-ol3ex.js" target="_blank">252-ol3ex.js source</a> to see how this is done.</p>
     </div>
     <div id="tags">drag, feature, vector, editing</div>
    </div>
   </div>
  </div>
  <!--
  <script src="../resources/jquery.min.js" type="text/javascript"></script>
  <script src="../resources/example-behaviour.js" type="text/javascript"></script>
  -->
  <!-- ディレクトリ修正
   jQuery Minified版と
   example-behaviour.js(Examples用 JSコード[文字コードなど])
  -->
  <script src="v3.1.1/resources/jquery.min.js" type="text/javascript"></script>
  <script src="v3.1.1/resources/example-behaviour.js" type="text/javascript"></script>
  <!--
  <script src="loader.js?id=drag-features" type="text/javascript"></script>
  -->
  <!-- ファイル修正 -->  <!-- ディレクトリ修正 -->
  <script src="loader.js?id=252-ol3ex" type="text/javascript"></script>
 </body>
</html>

2014年1月21日火曜日

34 - 編集ツールバー(Editing Toolbar) 3 - 移動ボタンを追加

34-3 Editing Toolbar に移動ボタンを追加する
「ol015-nippon_bmi_akiruno_pgis.html」 ファイルを続けて使います。
移動ボタンは次のようなものを作成して、"OpenLayers-2.13.1/theme/default/img/ に保存しました。


drag_feature_on.png

drag_feature_off.png


<style> に移動ボタンのスタイルを追加

--
// ここから追加
 .olControlDragFeatureItemActive { 
  background-image: url(OpenLayers-2.13.1/theme/default/img/   drag_feature_on.png);
  background-repeat: no-repeat;
  background-position: 0px 1px;
 }
 .olControlDragFeatureItemInactive { 
  background-image: url(OpenLayers-2.13.1/theme/default/img/drag_feature_off.png);
  background-repeat: no-repeat;
  background-position: 0px 1px;
 }
// ここまで
---

移動ボタンのコードを追加

---
   new OpenLayers.Control.DrawFeature(
    vectors,
    OpenLayers.Handler.Polygon,
    {
     title: "Draw Polygon",
     displayClass: 'olControlDrawFeaturePolygon',
     multi: true
   }),
// ここから追加
   new OpenLayers.Control.DragFeature(
    vectors,
    {
     title: "Drag Feature",
     displayClass: 'olControlDragFeature'
   }),
// ここまで
   new OpenLayers.Control.SelectFeature(
---


2014年1月14日火曜日

33 - マウスでフィーチャを描画 3 - ポリゴン(多角形)を移動する

33-3a ポリゴン(多角形)を移動する
examples フォルダにある「Drag Feature Example(drag-feature.html)」を参考に マウスで移動してみます。
「ol014-nippon_bmi_akiruno_pgis.html」 ファイルを続けて使います。

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







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






c 次のように「drag-feature.html」の内容の一部をコピーして「ol014-nippon_bmi_akiruno_pgis.html」に貼り付け、修正します。

---


 drawControls = {
  polygon: new OpenLayers.Control.DrawFeature(
   vectors, OpenLayers.Handler.Polygon),
  drag: new OpenLayers.Control.DragFeature(
   vectors), // 追加
  select: new OpenLayers.Control.SelectFeature(
   vectors,


---
   <li>
    <input type="radio" name="type" value="polygon" id="polygonToggle" onclick="toggleControl(this);" />
    <label for="polygonToggle">draw polygon</label>
   </li>

<!-- ここから追加 -->
  <li>
    <input type="radio" name="type" value="drag" id="dragToggle" onclick="toggleControl(this);" />
    <label for="dragToggle">drag feature</label>
  </li>
<!--  ここまで -->

   <li>
    <input type="radio" name="type" value="selecthover" id="selecthoverToggle" onclick="toggleControl(this);" />
    <label for="selecthoverToggle">Select features on hover</label>
   </li>
---














33-3b ポリゴン(多角形)を複数選択して移動する
このままでは、フィーチャを複数選択して同時に移動できませんでした。

Stack Overflow の

「Drag/Move Multiple Selected Features - OpenLayers」
http://stackoverflow.com/questions/4389221/drag-move-multiple-selected-features-openlayers

を参考にコードを次のように修正します。

---
<script type="text/javascript">
 var map, layer0, layer1, layer2, layer3, layer4, drawControls, vectors; // "vectors" 追加
---
  vectors = new OpenLayers.Layer.Vector("Vector Layer", { // "var" 削除
   renderers: renderer
  });
---
  drawControls = {
   polygon: new OpenLayers.Control.DrawFeature(
    vectors, OpenLayers.Handler.Polygon),
   drag: new OpenLayers.Control.DragFeature(
    vectors,
    // ここから追加 
    {
     onStart: startDrag,
     onDrag: doDrag,
     onComplete: endDrag
    }
    // ここまで
   ),
   select: new OpenLayers.Control.SelectFeature(
    vectors,
    {
     clickout: false, toggle: false,
     multiple: false, hover: false,
     toggleKey: "ctrlKey", // ctrl key removes from selection
     multipleKey: "shiftKey", // shift key adds to selection
     box: true,
     // ここから追加
     onSelect: addSelected,
     onUnselect: clearSelected
     // ここまで
    }
   ),
   selecthover: new OpenLayers.Control.SelectFeature(
    vectors,
    {
     multiple: false, hover: true,
     toggleKey: "ctrlKey", // ctrl key removes from selection
     multipleKey: "shiftKey" // shift key adds to selection
    }
   )
  };
---
// ここから追加
  /* Keep track of the selected features */
  function addSelected(feature) {
   selectedFeatures.push(feature);
  }
  /* Clear the list of selected features */
  function clearSelected(feature) {
   selectedFeatures = [];
  }
  /* Feature starting to move */
  function startDrag(feature, pixel) {
   // save hash with selected features start position
   lastPixel = pixel;
  }
  /* Feature moving */
  function doDrag(feature, pixel) {
   for (f in selectedFeatures) {
    if (feature != selectedFeatures[f]) {
     var res = map.getResolution();
     selectedFeatures[f].geometry.move(res * (pixel.x - lastPixel.x), res * (lastPixel.y - pixel.y));
     vectors.drawFeature(selectedFeatures[f]);
    }
   }
   lastPixel = pixel;

  /* because DragFeatures own handler overwrites dragSelected.lastPixel with pixel before this is called, calculate drag vector from movement of "feature" */
  }
  /* Featrue stopped moving */
  function endDrag(feature, pixel) {
   for (f in selectedFeatures) {
    f.state = OpenLayers.State.UPDATE;
   }
  }
// ここまで

 </script>
</head>
---


「select feature」をクリックしてラジオボタンをオンにし、「select features in a box」にチェックがついていることを確認して、複数のフィチャーをドラッグして選択します。
(最初の選択ではフィーチャが1つしか選択されませんでした。原因はわかりませんでした。1度選択を外して、もう一度選択します。)




フィーチャを1つだけドラッグすると、選択したフィーチャが一緒に移動します。