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

2015年3月2日月曜日

2 - ol3.2ex 71b -OverviewMap control, advanced 2

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

「271-ol3ex.js」
var overviewMapControl = new ol.control.OverviewMap({
/** new ol.control.OverviewMap(opt_options)
 * Create a new control with a map acting as an 
 * overview map for an other defined map.
 * もうひとつの定義されたマップの概要マップとして
 * 動作するマップで新しいコントロールを作成します。
 * (ol3 API[説明は Stable Only のチェックを外すと表示])
 */
/** see in overviewmap-custom.html to see the 
 * custom CSS used
 * 使用されたカスタム CSS を知るために 
 * overviewmap-custom.html をみてください。
 */
 className: 'ol-overviewmap ol-custom-overviewmap',
 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)
    */
    'url': '//{a-c}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png'
   })
  })
 ],
 collapseLabel: '\u00BB',
 /** collapseLabel:
  * Text label to use for the expanded overviewmap 
  * button. Default is «. Instead of text, also a 
  * Node (e.g. a span element) can be used.
  * overviewmap 展開ボタンに使用されるテキストラベル。
  * デフォルトは、 << です。テキストの替りに、ノード(例えば、
  * span エレメント)が使用できます。
  * (ol3 API[説明は Stable Only のチェックを外すと表示])
  */
 label: '\u00AB',
 /** collapseLabel:
  * Text label to use for the expanded overviewmap 
  * button. Default is «. Instead of text, also a 
  * Node (e.g. a span element) can be used.
  * overviewmap 折りたたみボタンに使用されるテキストラベル。
  * デフォルトは、 .. です。テキストの替りに、ノード(例えば、
  * span エレメント)が使用できます。
  * (ol3 API[説明は Stable Only のチェックを外すと表示])
  */
 collapsed: false // 折りたたみ
});
var map = new ol.Map({
 controls: ol.control.defaults().extend([
 /** 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
  */
  overviewMapControl
 ]),
 interactions: ol.interaction.defaults().extend([
 /** 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 を参照してください。)
  */
  new ol.interaction.DragRotateAndZoom()
  /** ol.interaction.DragRotateAndZoom 
   * Allows the user to zoom and rotate the map by 
   * clicking and dragging on the map. By default, 
   * this interaction is limited to when the shift 
   * key is held down.
   * This interaction is only supported for mouse 
   * devices.
   * And this interaction is not included in the 
   * default interactions.
   * マップ上をクリックとドラッグすることで、マップをズームし、
   * 回転することを許可します。デフォルトでは、このインターラク
   * ションは、シフトキーを押しているときに制限されています。
   * このインターラクションは、マウスデバイスだけサポートします。
   * 阻止t,このインターラクションは、デフォルトのインターラク
   * ションに含まれません。(ol3 API)
   */
 ]),
 layers: [
  new ol.layer.Tile({
   source: new ol.source.OSM()
  })
 ],
 target: 'map',
 view: new ol.View({
  center: [500000, 6000000],
  zoom: 7
 })
});

2 - ol3.2ex 71a - OverviewMap control, advanced 1

「OverviewMap control, advanced (overviewmap-custom.html)」を参考に地図を表示してみます。
説明に次のようにあります。

This example demonstrates how you can customize the overviewmap control using its supported options as well as defining custom CSS. You can also rotate the map using the shift key to see how the overview map reacts.

この例では、カスタムCSSを定義するのと同じように、サポートされているオプションを使用して、overviewmap コントロールをカスタマイズする方法を示します。また、概観マップがどのように反応するかを見るために、Shiftキーを使用してマップを回転させることができます。

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





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





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



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








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











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


「271-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.2.1/css/ol.css" type="text/css">
  <link rel="stylesheet" href="v3.2.1/resources/bootstrap/css/bootstrap.min.css" type="text/css">
  <link rel="stylesheet" href="v3.2.1/resources/layout.css" type="text/css">
  <link rel="stylesheet" href="v3.2.1/resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
  <style type="text/css">
   .ol-custom-overviewmap,
   .ol-custom-overviewmap.ol-uncollapsible {
    bottom: auto;
    left: auto;
    right: 0;
    top: 0;
   }
   .ol-custom-overviewmap:not(.ol-collapsed)  {
    border: 1px solid black;
   }
   .ol-custom-overviewmap .ol-overviewmap-map {
    border: none;
    width: 300px;
   }
   .ol-custom-overviewmap .ol-overviewmap-box {
    border: 2px solid red;
   }
   .ol-custom-overviewmap:not(.ol-collapsed) button{
    bottom: auto;
    left: auto;
    right: 1px;
    top: 1px;
   }
   .ol-rotate {
    top: 170px;
    right: 0;
   }
  </style>
  <title>ol3 OverviewMap control example with advanced customization</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.2.1/examples/"><img src="v3.2.1/resources/logo.png"> OpenLayers 3 Examples</a>
    </div>
   </div>
  </div>
  <div class="container-fluid">
   <h4 id="title">OverviewMap control, advanced</h4>
   <div id="map" class="map"></div>
   <div class="row-fluid">
    <p id="shortdesc">Example of OverviewMap control customization.</p>
    <div id="docs">
     <!--
     <p>See the <a href="overviewmap-custom.js" target="_blank">overviewmap-custom.js source</a> to see how this is done.</p>
     -->
     <!-- ファイル修正 -->
     <p>See the <a href="271-ol3ex.js" target="_blank">271-ol3ex.js source</a> to see how this is done.</p>
     <p>This example demonstrates how you can customize 
     the overviewmap control using its supported options as 
     well as defining custom CSS. You can also rotate the 
     map using the shift key to see how the overview map 
     reacts.</p>
    </div>
    <div id="tags">overview, overviewmap</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.2.1/resources/jquery.min.js" type="text/javascript"></script>
  <script src="v3.2.1/resources/example-behaviour.js" type="text/javascript"></script>
  <!--
  <script src="loader.js?id=overviewmap-custom" type="text/javascript"></script>
  -->
  <!-- ファイル修正 -->  <!-- ディレクトリ修正 -->
  <script src="loader.js?id=271-ol3ex" type="text/javascript"></script>
 </body>
</html>

2 - ol3.2ex 70b -OverviewMap control 2

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

「270-ol3ex.js」
var map = new ol.Map({
 controls: ol.control.defaults().extend([
 /** 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
  */
  new ol.control.OverviewMap()
  /** new ol.control.OverviewMap(opt_options)
   * Create a new control with a map acting as an 
   * overview map for an other defined map.
   * もうひとつの定義されたマップの概要マップとして
   * 動作するマップで新しいコントロールを作成します。
   * (ol3 API[説明は Stable Only のチェックを外すと表示])
   */
 ]),
 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)
   */
  })
 ],
 target: 'map',
 view: new ol.View({
  center: [500000, 6000000],
  zoom: 7
 })
});

2 - ol3.2ex 70a - OverviewMap control 1

「OverviewMap control (overviewmap.html)」を参考に地図を表示してみます。

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





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





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



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








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











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


「270-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.2.1/css/ol.css" type="text/css">
  <link rel="stylesheet" href="v3.2.1/resources/bootstrap/css/bootstrap.min.css" type="text/css">
  <link rel="stylesheet" href="v3.2.1/resources/layout.css" type="text/css">
  <link rel="stylesheet" href="v3.2.1/resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
  <title>ol3 OverviewMap control 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.2.1/examples/"><img src="v3.2.1/resources/logo.png"> OpenLayers 3 Examples</a>
    </div>
   </div>
  </div>
  <div class="container-fluid">
   <h4 id="title">OverviewMap control</h4>
   <div id="map" class="map"></div>
   <div class="row-fluid">
    <p id="shortdesc">Example of OverviewMap control.</p>
    <div id="docs">
     <!--
     <p>See the <a href="overviewmap.js" target="_blank">overviewmap.js source</a> to see how this is done.</p>
     -->
     <!-- ファイル修正 -->
     <p>See the <a href="270-ol3ex.js" target="_blank">270-ol3ex.js source</a> to see how this is done.</p>
    </div>
    <div id="tags">overview, overviewmap</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.2.1/resources/jquery.min.js" type="text/javascript"></script>
  <script src="v3.2.1/resources/example-behaviour.js" type="text/javascript"></script>
  <!--
  <script src="loader.js?id=overviewmap" type="text/javascript"></script>
  -->
  <!-- ファイル修正 -->  <!-- ディレクトリ修正 -->
  <script src="loader.js?id=270-ol3ex" type="text/javascript"></script>
 </body>
</html>

2008年10月16日木曜日

OpenLayers 15g Overview(オーバービュー、リファレンス)

Overview Map(overviewmap.html)を参考に、リファレンス(参照)地図を表示します。
OpenLayers.Map のオプションを次のように修正します。
このとき、OpenLayers.Control.PanZoomBar を削除します。
map.addControl で Overview を設定するとエラーになるためです。

---
function init(){
OpenLayers.ProxyHost="/cgi-bin/proxy.cgi?url=";
var mapOptions = {
// controls: [new OpenLayers.Control.PanZoomBar()],
numZoomLevels: 10,
maxResolution: 'auto',
units: 'meters',
maxExtent: extent
};
map = new OpenLayers.Map('map', mapOptions);
---

地図の表示部分のスクリプトに OpenLayers.Control.OverviewMap を次のように追加します。

---
map.addLayers([layer1, layer3, layer4, layer5, layer6, layer7, layer8]);
var panel = new OpenLayers.Control.NavToolbar({'div':OpenLayers.Util.getElement('paneldiv')});
map.addControl(panel);
map.zoomToMaxExtent();
map.setOptions({restrictedExtent: extent});
var click = new OpenLayers.Control.Click();
map.addControl(click);
click.activate();
map.events.register("moveend", null, displayZoom);
map.fractionalZoom = input.checked;
map.zoomTo(Math.round(map.zoom));
nav = new OpenLayers.Control.Navigation({'zoomWheelEnabled': false});
map.addControl(nav);
map.addControl(new OpenLayers.Control.LayerSwitcher());

//ここから追加
var controlOptions = {
mapOptions: mapOptions
};
var overview = new OpenLayers.Control.OverviewMap(controlOptions);
map.addControl(overview);
overview.maximizeControl();
//ここまで
}
function displayZoom() {
document.getElementById("zoom").innerHTML = map.zoom.toFixed(4);
}
</script>
---