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

2019年8月26日月曜日

ol5.3ex 2 - OSM Vector Tiles

「OSM Vector Tiles (osm-vector-tiles.html.html) 」の説明に次のようにあります。

A simple vector tiles map with Mapzen vector tiles. This example uses the TopoJSON format's layerName option to determine the layer ("water", "roads", "buildings") for styling. Note: [ol/format/MVT] is an even more efficient format for vector tiles.

Mapzen ベクタタイルを使用した単純なベクタタイルマップ。この例は、スタイリングのためのレイヤ("water", "roads", "buildings")を決定するために TopoJSON フォーマットの layerName オプションを使用します。重要:[ol/format/MVT] は、ベクタタイルのさらに効果的なフォーマットです。

訳者注:Mapzen は、2018年1月でサービスを停止しました。

2015年12月31日木曜日

2 - ol3.12ex 141b - OSM Vector Tiles 2

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

「2141-ol3ex.js」
var format = new ol.format.TopoJSON();
/** ol.format.TopoJSON 
 * Feature format for reading and writing data 
 * in the TopoJSON format.
 * TopoJSON フォーマットでデータを読み書きするためのフィー
 * チャのフォーマット。(ol3 API)
 */
var tileGrid = ol.tilegrid.createXYZ({ maxZoom: 19 });
/** ol.tilegrid.createXYZ(opt_options)
  * Creates a tile grid with a standard XYZ tiling 
  * scheme.
  * 標準のXYZタイルスキーマを持つタイルグリッドを作成します。
 * (ol3 API[説明は Stable Only のチェックを外すと表示])
  */
 /** maxZoom:
  * Maximum zoom. The default is ol.DEFAULT_MAX_ZOOM. 
  * This determines the number of levels in the grid 
  * set. For example, a maxZoom of 21 means there are 
  * 22 levels in the grid set.
  * 最大ズーム。デフォルトはol.DEFAULT_MAX_ZOOMです。これは、
  * グリッドのセット内のレベルの数を決定します。たとえば、21 
  * のmaxZoom は、グリッドセット内に 22 のレベルがあることを
  * 意味します。
 * (ol3 API[説明は Stable Only のチェックを外すと表示])
  */
var roadStyleCache = {};
var roadColor = {
 'major_road': '#776',
 'minor_road': '#ccb',
 'highway': '#f39'
};
var landuseStyleCache = {};
var buildingStyle = 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 のチェックを外すと表示])
 */
 fill: new ol.style.Fill({
 /** ol.style.Fill 
  * Set fill style for vector features.
  * ベクタフィーチャの塗りつぶしスタイルを設定。(ol3 API)
  */
  color: '#666',
  opacity: 0.4
 }),
 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 のチェックを外すと表示])
  */
  color: '#444',
  /** color:
   * Color. See ol.color for possible formats. Default 
   * null; if null, the Canvas/renderer default black 
   * will be used.
   * 色。可能なフォーマットについては ol.color を参照してくださ
   * い。デフォルトは null; null の場合、Canvas/renderer デ
   * フォルトの黒が使用されます。
   * (ol3 API[説明は Stable Only のチェックを外すと表示])
   */
  width: 1
 })
});
var map = new ol.Map({
 layers: [
  new ol.layer.VectorTile({
  /** ol.layer.VectorTile
   * Layer for vector tile data that is rendered client-side.
   * クライアント側でレンダリングされるベクタタイルデータのレイ
   * ヤ。
   * (ol3 API[説明は Stable Only のチェックを外すと表示])
   */
   source: new ol.source.VectorTile({
   /** ol.source.VectorTile
    * Class for layer sources providing vector data 
    * divided into a tile grid, to be used with 
    * ol.layer.VectorTile. Although this source receives 
    * tiles with vector features from the server, it is 
    * not meant for feature editing. Features are optimized 
    * for rendering, their geometries are clipped at or 
    * near tile boundaries and simplified for a view 
    * resolution. See ol.source.Vector for vector sources 
    * that are suitable for feature editing. 
    * ol.layer.VectorTile を使用するために、タイルのグリッドに
    * 分割されたベクタデータを提供するレイヤソースのクラス。この
    * ソースは、サーバからのベクタフィーチャと共にタイルを受信し
    * ますが、それはフィーチャ編集のためのものではありません。
    * フィーチャは、レンダリングのために最適化され、そのジオメト
    * リはタイルに、または、その境界付近にクリップされ、ビューの
    * 解像度のために簡略化されます。フィーチャの編集に適したベク
    * タソースための ol.source.Vector を参照してください。
    * (ol3 API[説明は Stable Only のチェックを外すと表示])
    */
    format: format,
    /** format:
     * Feature format for tiles. Used and required by the 
     * default tileLoadFunction.
     * タイルのフィーチャフォーマット。デフォルトの 
     * tileLoadFunction によって使用され必要とされます。
     * (ol3 API[説明は Stable Only のチェックを外すと表示])
     */
    tileGrid: tileGrid,
    url: 'http://{a-c}.tile.openstreetmap.us/' +
     'vectiles-water-areas/{z}/{x}/{y}.topojson'
   }),
   style: new ol.style.Style({
    fill: new ol.style.Fill({
     color: '#9db9e8'
    })
   })
  }),
  new ol.layer.VectorTile({
   source: new ol.source.VectorTile({
    format: format,
    tileGrid: tileGrid,
    url: 'http://{a-c}.tile.openstreetmap.us/' +
     'vectiles-highroad/{z}/{x}/{y}.topojson'
   }),
   style: function(feature, resolution) {
   /** style:
    * Layer style. See ol.style for default style which 
    * will be used if this is not defined.
    * レイヤースタイル。これが定義されていない場合に使用される
    * デフォルトスタイルの ol.style を参照してください。
    * (ol3 API)
    */
    var kind = feature.get('kind');
    /** get(key)
     * Gets a value.Gets a value.(ol3 API)
     */
    var railway = feature.get('railway');
    var sort_key = feature.get('sort_key');
    var styleKey = kind + '/' + railway + '/' + sort_key;
    var style = roadStyleCache[styleKey];
    if (!style) {
     var color, width;
     if (railway) {
      color = '#7de';
      width = 1;
     } else {
      color = roadColor[kind];
      width = kind == 'highway' ? 1.5 : 1;
      /** 条件演算子 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])
       */
     }
     style = new ol.style.Style({
      stroke: new ol.style.Stroke({
       color: color,
       width: width
      }),
      zIndex: sort_key
     });
     roadStyleCache[styleKey] = style;
    }
    return style;
   }
  }),
  new ol.layer.VectorTile({
   source: new ol.source.VectorTile({
    format: format,
    tileGrid: tileGrid,
    url: 'http://{a-c}.tile.openstreetmap.us/' +
     'vectiles-buildings/{z}/{x}/{y}.topojson'
   }),
   style: function(f, resolution) {
    return (resolution < 10) ? buildingStyle : null;
   }
  }),
  new ol.layer.VectorTile({
   source: new ol.source.VectorTile({
    format: format,
    tileGrid: tileGrid,
    url: 'http://{a-c}.tile.openstreetmap.us/' +
     'vectiles-land-usages/{z}/{x}/{y}.topojson'
   }),
   visible: false,
   /** visible:
    * Visibility. Default is true (visible).
    * (ol3 API)
    */
   style: function(feature, resolution) {
    var kind = feature.get('kind');
    var styleKey = kind;
    var style = landuseStyleCache[styleKey];
    if (!style) {
     var color, width;
     color = {
      'parking': '#ddd',
      'industrial': '#aaa',
      'urban area': '#aaa',
      'park': '#76C759',
      'school': '#DA10E7',
      'garden': '#76C759',
      'pitch': '#D58F8D',
      'scrub': '#3E7D28',
      'residential': '#4C9ED9'
     }[kind];
     width = kind == 'highway' ? 1.5 : 1;
     style = new ol.style.Style({
      stroke: new ol.style.Stroke({
       color: color,
       width: width
      }),
      fill: new ol.style.Fill({
       color: color,
       opacity: 0.5
      })
     });
     landuseStyleCache[styleKey] = style;
    }
    return style;
   }
  })
 ],
 target: 'map',
 view: new ol.View({
  center: ol.proj.fromLonLat([-74.0064, 40.7142]),
  /** ol.proj.fromLonLat(coordinate, opt_projection)
   * Transforms a coordinate from longitude/latitude to a 
   * different projection.
   * 緯度/経度座標から異なる投影に変換します。(ol3 API)
   */
  maxZoom: 19,
  zoom: 15
 })
});

2 - ol3.12ex 141a - OSM Vector Tiles 1

「OSM Vector Tiles (osm-vector-tiles.html)」を参考に地図を表示してみます。
説明に次のようにあります。

A simple vector tiles map with OpenStreetMap vector tiles. Note: The tiles used in this example are not optimized for rendering - they clip tiles exactly at the tile boundary instead of adding a buffer, and use geographic coordinates instead of tile relative pixel coordinates in view projection.

OpenStreetMap のベクタタイルを使用する単純なベクトルタイルマップ。注意:この例は使用されるタイルがレンダリングのために最適化されていません - これらはバッファを追加する代わりに、正確にタイル境界でタイルをクリップし、ビュー投影法の相対的なピクセル座標の代わりに、タイルの地理座標を使用しています。

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





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





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




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








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











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

「2141-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>

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

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

  <link rel="stylesheet" href="v3.12.1/examples/osm-vector-tiles.css">
  <script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=fetch"></script>
  <title>OSM Vector Tiles</title>
 </head>
 <body>
  <!-- 
  bootstrap-combined.min.css, ol.css, layout.css,
  CSSファイルで設定されたセレクタを使用。
  -->
  <header class="navbar" role="navigation">
   <div class="container" id="navbar-inner-container">
    <!--
    <a class="navbar-brand" href="./"><img src="./resources/logo-70x70.png"> OpenLayers 3 Examples</a>
    -->
    <!-- ディレクトリ修正 -->
    <a class="navbar-brand" href="v3.12.1/examples/"><img src="v3.12.1/examples/resources/logo-70x70.png"> OpenLayers 3 Examples</a>
   </div>
  </header>
  <div class="container-fluid">
   <div class="row-fluid">
    <div class="span12">
     <h4 id="title">OSM Vector Tiles</h4>
     <div id="map" class="map"></div>
    </div>
   </div>
   <div class="row-fluid">
    <div class="span12">
     <p id="shortdesc">Using OpenStreetMap vector tiles. </p>
     <div id="docs"><p>A simple vector tiles map with 
      OpenStreetMap vector tiles. <strong>Note</strong>: 
      The tiles used in this example are not optimized for 
      rendering - they clip tiles exactly at the tile 
      boundary instead of adding a buffer, and use geographic 
      coordinates instead of tile relative pixel coordinates 
      in view projection.</p>
     </div>
     <div id="api-links">Related API documentation: 
      <ul class="inline">
       <li>
        <!-- <a href="../apidoc/ol.Map.html" title="API documentation for ol.Map">ol.Map</a> -->
        <a href="v3.12.1/apidoc/ol.Map.html" title="API documentation for ol.Map">ol.Map</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.View.html" title="API documentation for ol.View">ol.View</a> -->
        <a href="v3.12.1/apidoc/ol.View.html" title="API documentation for ol.View">ol.View</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.format.TopoJSON.html" title="API documentation for ol.format.TopoJSON">ol.format.TopoJSON</a> -->
        <a href="v3.12.1/apidoc/ol.format.TopoJSON.html" title="API documentation for ol.format.TopoJSON">ol.format.TopoJSON</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.layer.VectorTile.html" title="API documentation for ol.layer.VectorTile">ol.layer.VectorTile</a> -->
        <a href="v3.12.1/apidoc/ol.layer.VectorTile.html" title="API documentation for ol.layer.VectorTile">ol.layer.VectorTile</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.proj.html" title="API documentation for ol.proj">ol.proj</a> -->
        <a href="v3.12.1/apidoc/ol.proj.html" title="API documentation for ol.proj">ol.proj</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.proj.html" title="API documentation for ol.proj">ol.proj</a> -->
        <a href="v3.12.1/apidoc/ol.proj.html" title="API documentation for ol.proj">ol.proj</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.source.VectorTile.html" title="API documentation for ol.source.VectorTile">ol.source.VectorTile</a> -->
        <a href="v3.12.1/apidoc/ol.source.VectorTile.html" title="API documentation for ol.source.VectorTile">ol.source.VectorTile</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.style.Fill.html" title="API documentation for ol.style.Fill">ol.style.Fill</a> -->
        <a href="v3.12.1/apidoc/ol.style.Fill.html" title="API documentation for ol.style.Fill">ol.style.Fill</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.style.Stroke.html" title="API documentation for ol.style.Stroke">ol.style.Stroke</a> -->
        <a href="v3.12.1/apidoc/ol.style.Stroke.html" title="API documentation for ol.style.Stroke">ol.style.Stroke</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.style.Style.html" title="API documentation for ol.style.Style">ol.style.Style</a> -->
        <a href="v3.12.1/apidoc/ol.style.Style.html" title="API documentation for ol.style.Style">ol.style.Style</a>
       </li>
      </ui>
     </div>
   </div>
  </div>
  <div class="row-fluid">
    <div id="source-controls">
     <a id="copy-button">
      <i class="fa fa-clipboard"></i> Copy
     </a>
     <a id="jsfiddle-button">
      <i class="fa fa-jsfiddle"></i> Edit
     </a>
    </div>
    <form method="POST" id="jsfiddle-form" target="_blank" action="http://jsfiddle.net/api/post/jquery/1.11.0/">
    <textarea class="hidden" name="js">
// --- 省略 ---
&lt;/html&gt;</code></pre>
   </div>
  </div>
  <!--
  <script src="./resources/common.js"></script>
  <script src="./resources/prism/prism.min.js"></script>
  -->
  <!-- ディレクトリ修正
   CommonJS と
   prism.js
 -->
  <script src="v3.12.1/examples/resources/common.js"></script>
  <script src="v3.12.1/examples/resources/prism/prism.min.js"></script>
  <!-- 
  <script src="loader.js?id=osm-vector-tiles"></script>
  -->
  <!-- ファイル修正 -->  <!-- ディレクトリ修正 -->
  <script src="loader.js?id=2141-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 のコンテキストメニューが表示されると動作しています。

2014年11月30日日曜日

2 - ol3ex 30b - OSM XML example 2

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

Overpass APIは、「Overpass API-OpenStreetMap Wiki(http://wiki.openstreetmap.org/wiki/Overpass_API)」の「Introduction」に、次のようにあります。

****
The Overpass API (or OSM3S) is a read-only API that serves up custom selected parts of the OSM map data. It acts as a database over the web: the client sends a query to the API and gets back the data set that corresponds to the query.
オーバーパス API(または OSM3S)は、OSM マップデータのクライアントが選択した部分を提供している読み取り専用の API です。これは、Web 上のデータベースとして機能します。すなわち、クライアントは、API にクエリを送信し、クエリに対応するデータセットを受け取ります。

Unlike the main API, which is optimized for editing, Overpass API is optimized for data consumers that need a few elements within a glimpse or up to roughly 100 million elements in some minutes, both selected by search criteria like e.g. location, type of objects, tag properties, proximity, or combinations of them. It acts as a database backend for various services.
編集用に最適化されている主要な API とは異なり、オーバーパス API は、検索基準、(例えば、場所、オブジェクトの種類、タグプロパティ、近接、またはそれらの組み合わせのような)で選択された、ちらっと見る、または、数分で最大およそ1億の要素のうち、いくつかの要素を必要とするデータコンシューマ向けに最適化されています。それは、様々なサービスのためのデータベースのバックエンドとして機能します。

Overpass API has a powerful query language (language guide, language reference, an IDE) beyond XAPI, but also has a compatibility layer to allow a smooth transition from XAPI.*
オーバーパスAPIは、XAPI 越しに強力なクエリ言語(言語ガイド、言語リファレンス、IDE)を持っていますが、また、XAPI からの円滑な移行を可能にする互換性レイヤを持っています。

To support small and well scaling OSM main services, Overpass API is run as a third party service. You can use the public visible instances:
小さくてうまいスケーリング OSM のメインサービスをサポートするために、オーバーパス API は、サードパーティのサービスとして実行されます。あなたは、パブリックビジブルインスタンスを使用することができます。

http://overpass-api.de/ with query base address http://overpass-api.de/api/ (4 physical cores, 32 GB RAM).
http://overpass.osm.rambler.ru/ with query base address http://overpass.osm.rambler.ru/cgi/ (8 cores, 64 GB RAM).
Overpass API on openstreetmap.fr
*****

「230-ol3ex.js」
var styles = {
 'amenity': {
  'parking': [
   new ol.style.Style({
   /** ol.style.Style 
    * Base class for vector feature rendering styles.
    * ベクタフィーチャがスタイルを描画するための基本クラス。
    * (ol3 API)
    */
    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(170, 170, 170, 1.0)',
     width: 1
    }),
    fill: new ol.style.Fill({
    /** ol.style.Fill 
     * Set fill style for vector features.
     * ベクタフィーチャの塗りつぶしスタイルを設定。(ol3 API)
     */
     color: 'rgba(170, 170, 170, 0.3)'
    })
   })
  ]
 },
 'building': {
  '.*': [
   new ol.style.Style({
    zIndex: 100,
    stroke: new ol.style.Stroke({
     color: 'rgba(246, 99, 79, 1.0)',
     width: 1
    }),
    fill: new ol.style.Fill({
     color: 'rgba(246, 99, 79, 0.3)'
    })
   })
  ]
 },
 'highway': {
  'service': [
   new ol.style.Style({
    stroke: new ol.style.Stroke({
     color: 'rgba(255, 255, 255, 1.0)',
     width: 2
    })
   })
  ],
  '.*': [
   new ol.style.Style({
    stroke: new ol.style.Stroke({
     color: 'rgba(255, 255, 255, 1.0)',
     width: 3
    })
   })
  ]
 },
 'landuse': {
  'forest|grass|allotments': [
   new ol.style.Style({
    stroke: new ol.style.Stroke({
     color: 'rgba(140, 208, 95, 1.0)',
     width: 1
    }),
    fill: new ol.style.Fill({
     color: 'rgba(140, 208, 95, 0.3)'
    })
   })
  ]
 },
 'natural': {
  'tree': [
   new ol.style.Style({
    image: new ol.style.Circle({
    /** ol.style.Circle
     * Set circle style for vector features.
     * ベクタフィーチャの円のスタイルを設定。(ol3 API)
     */
     radius: 2,
     fill: new ol.style.Fill({
      color: 'rgba(140, 208, 95, 1.0)'
     }),
     stroke: null
    })
   })
  ]
 }
};
var vectorSource = new ol.source.ServerVector({
/** ol.source.ServerVector 
 * A vector source in one of the supported formats, using 
 * a custom function to read in the data from a remote server.
 * リモートサーバからのデータを読むためのカスタムファンクション
 * (独自関数)を使うための、サポートされたフォーマットのベクタ
 * ソース。(ol3 API)
 */
 format: new ol.format.OSMXML(),
 /** ol.format.OSMXML 
  * Feature format for reading data in the OSMXML format.
  * OSMXML フォーマットのデータを読み込むためのフィーチャ
  * フォーマット(ol3 API)
  */
 loader: function(extent, resolution, projection) {
  var epsg4326Extent =
   ol.proj.transformExtent(extent, projection, 'EPSG:4326');
   /** ol.proj.transformExtent(extent, source, destination)
    * Transforms an extent from source projection to 
    * destination projection. This returns a new extent 
    * (and does not modify the original).
    * ソースの投影法から変換先の投影法へ範囲を変換します。
    * これは、新しい範囲(オリジナルを変形しません)を返します。
    * (ol3 API)
    */
  var url = 'http://overpass-api.de/api/xapi?map?bbox=' +
   epsg4326Extent.join(',');
  $.ajax(url).then(function(response) {
  /** $.ajax( [url] [, settings] )
   * 非同期HTTP通信(Ajax)を行い、データの取得・処理を行います。
   * [url] String リクエスト送信先のURL
   * [settings] Object Ajaxリクエストでのオプションを記述した
   * オブジェクト(jQuery)
   */
   vectorSource.addFeatures(vectorSource.readFeatures(response));
  });
 },
 strategy: ol.loadingstrategy.createTile(new ol.tilegrid.XYZ({
 /** ol.loadingstrategy 
  * Strategies for loading vector data.
  * ベクタデータをローディングするための方法。
  * createTile 
  * ol.loadingstrategy のメソッド
  * (ol3 API)
  */
 /** ol.tilegrid.XYZ
  * Set the grid pattern for sources accessing XYZ 
  * tiled-image servers.
  * XYZタイル画像サーバにアクセスするソースのグリッドパターンを
  * 設定します。(ol3 API)
  */
  maxZoom: 19
 })),
 projection: 'EPSG:3857'
});
var vector = new ol.layer.Vector({
/** ol.layer.Vector
 * Vector data that is rendered client-side.
 * クライアント側で描画されたベクタデータ。(ol3 API)
 */
 source: vectorSource,
 style: function(feature, resolution) {
  for (var key in styles) {
   var value = feature.get(key);
   /** get(key)
    * Gets a value.
    * (ol3 API[説明は Stable Only のチェックを外すと表示])
    */
    if (value !== undefined) {
     for (var regexp in styles[key]) {
      if (new RegExp(regexp).test(value)) {
      /** RegExp
       * パターンに従ったテキストにマッチする正規表現オブジェク
       * トを生成します。
       * (MDN[https://developer.mozilla.org/ja/docs/Web/
       *  JavaScript/Reference/Global_Objects/RegExp])
       */
       /** RegExp.prototype.test()
        * 正規表現と対象の文字列の間のマッチを調べるための検索を
        * 実行し、結果を示す真偽値 ( true / false )を返します。
        * (MDN[https://developer.mozilla.org/ja/docs/Web/
        * JavaScript/Reference/Global_Objects/RegExp/test])
        */
       return styles[key][regexp];
      }
     }
    }
  }
  return null;
 }
});
var raster = 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: 'Aerial',
  key: 'Ak-dzM...(省略)'
 })
});
var map = new ol.Map({
 layers: [raster, vector],
 target: document.getElementById('map'),
 controls: ol.control.defaults({
 /** controls
  * Controls initially added to the map. 
  * If not specified, ol.control.defaults() is used.
  * 初期設定で、マップに追加されたコントロール。
  * 明示されていなければ、ol.control.defaults() が使用されます。
  * (ol3 API)
  */
 /** ol.control.defaults()
  * デフォルトでは、マップに含まコントロールのセット。
  * 特に設定しない限り、これは、以下の各コントロールの
  * インスタンスを含むコレクションを返します。(API Doc より)
  * ol.control.Zoom, ol.control.Rotate, ol.control.Attribution
  */
  attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
  /** @type 
   * 値のタイプ(型)の説明 - 式などで表示
   * attributionOptions の値の型は、
   * olx.control.AttributionOptions の型を使用。
   * (@use JSDoc[http://usejsdoc.org/]より)
   */
  collapsible: false // 折りたたみ
  })
 }),
 view: new ol.View({
  center: [739218, 5906096],
  maxZoom: 19,
  zoom: 17
 })
});


2 - ol3ex 30a - OSM XML example 1

「OSM XML example(vector-osm.html)」を参考に地図を表示してみます。

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





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





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



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








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











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


「230-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.0.0/css/ol.css" type="text/css">
  <link rel="stylesheet" href="v3.0.0/resources/bootstrap/css/bootstrap.min.css" type="text/css">
  <link rel="stylesheet" href="v3.0.0/resources/layout.css" type="text/css">
  <link rel="stylesheet" href="v3.0.0/resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
  <title>OSM XML 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.0.0/examples/"><img src="v3.0.0/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="span4">
     <h4 id="title">OSM XML example</h4>
     <p id="shortdesc">Example of using the OSM XML source.  Vector data is loaded dynamically from a server using a tiling strategy.</p>
<!--
      <p>See the <a href="vector-osm.js" target="_blank">vector-osm.js source</a> to see how this is done.</p>
-->
       <!-- ファイル修正 -->
      <p>See the <a href="230-ol3ex.js" target="_blank">230-ol3ex.js source</a> to see how this is done.</p>
     </div>
     <div id="tags">vector, osm, xml, loading, server</div>
    </div>
    <div class="span4 offset4">
     <div id="info" class="alert alert-success">
      &nbsp;
     </div>
    </div>
   </div>
  </div>
<!--
  <script src="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.0.0/examples/jquery.min.js" type="text/javascript"></script>
  <script src="v3.0.0/resources/example-behaviour.js" type="text/javascript"></script>
<!--
  <script src="loader.js?id=tile-vector" type="text/javascript"></script>
-->
  <!-- ファイル修正 -->  <!-- ディレクトリ修正 -->
  <script src="loader.js?id=230-ol3ex" type="text/javascript"></script>

 </body>
</html>