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

2017年11月28日火曜日

2 - ol4.5ex 175b - Vector Tile Info vector-tile-info 2

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

「2175-ol4ex.js」
var map = new ol.Map({
 target: 'map',
 view: new ol.View({
  center: [0, 0],
  zoom: 2
 }),
 layers: [new ol.layer.VectorTile({
 /** ol.layer.VectorTile
  * Layer for vector tile data that is rendered client-side. 
  * クライアント側にレンダリングされるベクタタイルデータのレイ 
  * ヤ。
  * (ol4 API)
  */
  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 を参照してください。
   * (ol4 API)
   */
   format: new ol.format.MVT(),
   /** format:
    * Feature format for tiles. Used and required by the 
    * default tileLoadFunction.
    * タイルのためのフィーチャフォーマット。デフォルトの 
    * tileLoadFunction によって使用され、必須とされます。
    * (ol4 API)
    */
   /** ol.format.MVT
    * Feature format for reading data in the Mapbox MVT 
    * format.
    * Mapbox MVT フォーマットの描画データのためのフィーチャ
    * フォーマット。(ol4 API)
    */
   url: 'https://basemaps.arcgis.com/v1/arcgis/rest/services/World_Basemap/VectorTileServer/tile/{z}/{y}/{x}.pbf'
   /** url:
    * URL template. Must include {x}, {y} or {-y}, and {z} 
    * placeholders. A {?-?} template pattern, for example 
    * subdomain{a-f}.domain.com, may be used instead of 
    * defining each one separately in the urls option.
    * URLテンプレート。 {x}、{y}、{-y}、{z} のプレースホル
    * ダーが必要です。 urlsオプションでそれぞれ個別に定義する
    * 代わりに、例えばサブドメイン {a-f}.domain.com の、
    * {?-?} テンプレートパターンを使用することができます。
    * (ol4 API)
    */
  })
 })]
});
map.on('pointermove', showInfo);
/** on
 * Listen for a certain type of event.
 * あるタイプのイベントをリッスンします。
 * (ol4 API)
 */
var info = document.getElementById('info');
/** document.getElementById()
 * Returns a reference to the element by its ID; the ID 
 * is a string which can be used to uniquely identify 
 * the element, found in the HTML id attribute.
 * ID によってエレメントに参照を返します。ID は、HTML id 
 * 属性に見られるエレメントを一意に識別するために使用される
 * 文字列です。
 * (MDN[https://developer.mozilla.org/en-US/docs/Web/
 * API/Document/getElementById])
 */
function showInfo(event) {
 var features = map.getFeaturesAtPixel(event.pixel);
 /** getFeaturesAtPixel(pixel, opt_options)
  * Get all features that intersect a pixel on the 
  * viewport.
  * viewport(ビューポート)上のピクセルと交差するすべての
  * フィーチャを取得します。(ol4 API)
  */
 if (!features) {
  info.innerText = '';
  /** Node.innerText
   * Node.innerText is a property that represents the 
   * "rendered" text content of a node and its descendants. 
   * As a getter, it approximates the text the user would 
   * get if they highlighted the contents of the element 
   * with the cursor and then copied to the clipboard. 
   * This feature was originally introduced by Internet 
   * Explorer, and was formally specified in the HTML 
   * standard in 2016 after being adopted by all major 
   * browser vendors.
   * Node.innerTextは、ノードと子孫の「描画された」テキス
   * トコンテンツを表すプロパティです。getter と、カーソル
   * でエレメントのコンテンツを強調表示し、それからクリッ
   * プボードにコピーした場合取得するテキストを近似しま
   * す。この機能は、元々、Internet Explorer によって導
   * 入され、主要なブラウザベンダーによって採用された後、
   * 2016年に HTML標準に正式に制定されました。
   * (MDN[https://developer.mozilla.org/en-US/docs/Web/
   * API/Node/innerText])
   */
  /** getter
   * The get syntax binds an oject property to a function 
   * that will be called when that property is looked up.
   * get 構文は、オブジェクトプロパティを、そのプロパティが
   * 検索されたときに呼び出される関数にバインドします。
   * (MDN[https://developer.mozilla.org/en-US/docs/Web/
   * JavaScript/Reference/Functions/get])
   */
  info.style.opacity = 0;
  return;
 }
 var properties = features[0].getProperties();
 /** getProperties()
  * Get an object of all property names and values.
  * オブジェクトの全ての属性名と値を取得します。(ol4 API)
  */
 info.innerText = JSON.stringify(properties, null, 2);
 /** JSON.stringify()
  * The JSON.stringify() method converts a JavaScript 
  * value to a JSON string, optionally replacing values 
  * if a replacer function is specified, or optionally 
  * including only the specified properties if a replacer 
  * array is specified.
  * JSON.stringify()メソッドは、JavaScript 値を JSON 
  * 文字列に変換します。replacer 関数が指定されている場合は、
  * オプションで値を置換するか、または、replacer 配列が指定さ
  * れている場合は、指定のプロパティのみをオプションで含みま
  * す。
  * (MDN[https://developer.mozilla.org/en-US/docs/Web/
  * JavaScript/Reference/Global_Objects/JSON/stringify])
  */
 info.style.opacity = 1;
}


2 - ol4.5ex 175a - Vector Tile Info 1

「Vector Tile Info (vector-tile-info.html)」を参考に地図を表示してみます。
説明に次のようにあります。

Move your pointer over rendered features to display feature properties.

フィーチャプロパティを表示するために描画されたフィーチャ上でポインタを移動します。

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



b 「ファイルを開く」ウィンドウで、「user」->「public_html」->「eclipse-workspace」->「ol4proj」-> 「v4.5.0」->「examples」->「vector-tile-info.html」をクリックして選択し、「OK」ボタンをクリッ クします。
同じように「vector-tile-info.js」を開きます。



(この状態でファイル名をキーボードで打つと検索欄が表示されて候補が絞り込めます。)

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



d 「ファイル」ウィンドウで「ol4proj」->「v4.5.0」->「examples」をクリックして選択し、「ファイル名」を「2175-ol4ex.html」と入力し、「完了」ボタンをクリックします。
(「ファイル」->「新規」->「その他」をクリックし、「ウィザードを選択」ダイアログで「Web」->「HTMLファイル」からテンプレートも作成できます。)







e 「vector-tile-info.html」の内容をコピーして「2175-ol4ex.html」に貼り付け、修正します。

f 同じように、新規に「2175-ol4ex.js」ファイルを作成し、「vector-tile-info.js」の内容をコピーして貼り付け、修正します。「svector-tile-info-require.js」も「2175-ol4ex-require.js」に貼り付けます。
(「ファイル」->「新規」->「JavaScript ソース・ファイル」をクリックし、「新規 JavaScript ファイル」ダイアログでテンプレートも作成できます。)






「2175-ol3ex.html」
<!DOCTYPE html>
<html lang="en-US">
 <head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=Edge">
  <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.6/css/bootstrap.min.css" type="text/css">
  <link rel="stylesheet" href="./resources/prism/prism.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="vector-tile-info.css">

  <script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=fetch,requestAnimationFrame,Element.prototype.classList,URL"></script>
  <script src="./resources/zeroclipboard/ZeroClipboard.min.js"></script>
  <title>Vector Tile Info</title>
 </head>
 <body>
  <!-- 
  bootstrap-combined.min.css, ol.css, layout.css,
  CSSファイルで設定されたセレクタを使用。
  -->
  <header class="navbar" role="navigation">
   <div class="container">
    <div class="display-table pull-left" id="navbar-logo-container">
     <a class="navbar-brand" href="./"><img src="./resources/logo-70x70.png"> OpenLayers Examples</a>
    </div>
    <!-- menu items that get hidden below 768px width -->
    <nav class='collapse navbar-collapse navbar-responsive-collapse'>
     <ul class="nav navbar-nav pull-right">
      <li><a href="../doc">Docs</a></li>
      <li><a class="active" href="index.html">Examples</a></li>
      <li><a href="../apidoc">API</a></li>
      <li><a href="https://github.com/openlayers/openlayers">Code</a></li>
     </ul>
    </nav>
   </div>
  </header>
  <div class="container-fluid">
   <div id="latest-check" class="alert alert-warning alert-dismissible" role="alert" style="display:none">
    <button id="latest-dismiss" type="button" class="close" data-dismiss="alert" aria-label="Close">
     <span aria-hidden="true">&times;</span>
    </button>
     This example uses OpenLayers v<span>4.5.0</span>. 
     The <a id="latest-link" href="#" class="alert-link">latest</a>
     is v<span id="latest-version"></span>.
   </div>
   <div class="row-fluid">
    <div class="span12">
     <h4 id="title">Vector Tile Info</h4>
     <div id="map" class="map">
     <pre id="info" />
     </div>
    </div>
   </div>
   <div class="row-fluid">
    <div class="span12">
     <p id="shortdesc">Getting feature information from 
      vector tiles.</p>
     <div id="docs"><p>Move your pointer over rendered 
      features to display feature properties.</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>
       </li>,
       <li>
        <a href="../apidoc/ol.View.html" title="API documentation for ol.View">ol.View</a>
       </li>,
       <li>
        <a href="../apidoc/ol.format.MVT.html" title="API documentation for ol.format.MVT">ol.format.MVT</a>
       </li>,
       <li>
        <a href="../apidoc/ol.layer.VectorTile.html" title="API documentation for ol.layer.VectorTile">ol.layer.VectorTile</a>
       </li>,
       <li>
        <a href="../apidoc/ol.source.VectorTile.html" title="API documentation for ol.source.VectorTile">ol.source.VectorTile</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="codepen-button">
      <i class="fa fa-codepen"></i> Edit
     </a>
    </div>
    <form method="POST" id="codepen-form" target="_blank" action="https://codepen.io/pen/define/">
     <textarea class="hidden" name="title">Vector Tile Info</textarea>
     <textarea class="hidden" name="description">Getting feature information from vector tiles.</textarea>
     <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>
  <!-- 
  <script src="loader.js?id=svector-tile-info"></script>
  -->
  <!-- ファイル修正 -->
  <script src="loader.js?id=2175-ol4ex"></script>
 </body>
 <script>
  var packageUrl = 'https://raw.githubusercontent.com/openlayers/openlayers.github.io/build/package.json';
  fetch(packageUrl).then(function(response) {
  /** GlobalFetch.fetch()(This is an experimental technology)
   * The fetch() method of the GlobalFetch interface 
   * starts the process of fetching a resource. This 
   * returns a promise that resolves to the Response 
   * object representing the response to your request.
   * GlobalFetch インタフェースの fetch() メソッドは、リソー
   * スを取得する処理を開始します。これは要求に対する応答を表す 
   * Response オブジェクトに解決のプロミス(promise)を返しま
   * す。
   *(MDN[https://developer.mozilla.org/ja/docs/Web/API/
   * FGlobalFetch/fetch])
   */
   return response.json();
   /** Response(This is an experimental technology)
    * The Response interface of the Fetch API represents 
    * the response to a request.
    * Fetch API の Response インタフェースは、要求に対する応答
    * を表します。
    * (MDN[https://developer.mozilla.org/en-US/docs/Web/
    * API/Response])
    */
   /** Body.json()(This is an experimental technology)
    * The json() method of the Body mixin takes a Response 
    * stream and reads it to completion. It returns a 
    * promise that resolves with an object literal 
    * containing the JSON data.
    * Body mixin の json() メソッドは、Response ストリームを
    * 受け取り、それを完了させるために読み込みます。これは、
    * JSON データを含むオブジェクトリテラルで解決する約束
    * (promisee)を返します。
    * (MDN[https://developer.mozilla.org/en-US/docs/Web/
    * API/Body/json])
    */
  }).then(function(json) {
   var latestVersion = json.version;
   document.getElementById('latest-version').innerHTML = latestVersion;
   var url = window.location.href;
   var branchSearch = url.match(/\/([^\/]*)\/examples\//);
   /** String.prototype.match()
    * 正規表現 に対する 文字列 のマッチングの際に、そのマッチ結
    * 果を得るために使われます。
    * (MDN[https://developer.mozilla.org/ja/docs/Web/
    * JavaScript/Reference/Global_Objects/String/match])
    */
   var cookieText = 'dismissed=-' + latestVersion + '-';
   var dismissed = document.cookie.indexOf(cookieText) != -1;
   /** String.prototype.indexOf()
    * 呼び出す String オブジェクト 中で、指定された値が最初に現
    * れたインデックスを返します。fromIndex から検索を始め、値が
    * 見つからない場合は -1 を返します。
    * (MDN[https://developer.mozilla.org/ja/docs/Web/
    * JavaScript/Reference/Global_Objects/String/indexOf])
    */
   if (!dismissed && /^v[0-9\.]*$/.test(branchSearch[1]) && '4.1.0' != latestVersion) {
    var link = url.replace(branchSearch[0], '/latest/examples/');
    /** Location.replace()
     * The Location.replace() method replaces the current 
     * resource with the one at the provided URL. The 
     * difference from the assign() method is that after 
     * using replace() the current page will not be saved 
     * in session History, meaning the user won't be able 
     * to use the back button to navigate to it.
     * 指定された URL に現在の文書を置き換えます。 assign() メ
     * ソッドとの違いは、replace() を用いた後、現在のページは、
     * セッションの履歴には保持されないことです。つまり、ユーザ
     * は、置き換え前のページに戻るために、戻るボタンを使うこと
     * ができません。
     * (MDN[https://developer.mozilla.org/en-US/docs/Web/
     * API/Location/replace])
     */
    fetch(link, {method: 'head'}).then(function(response) {
     var a = document.getElementById('latest-link');
     a.href = response.status == 200 ? link : '../../latest/examples/';
     /** Response.status(This is an experimental technology)
      * The status read-only property of the Response 
      * interface contains the status code of the response 
      * (e.g., 200 for a success).
      * Response インタフェースの status 読み取り専用プロパティ
      * は、応答のステータス・コード(例えば、成功のために 200)
      * を含みます。
     * (MDN[https://developer.mozilla.org/en-US/docs/Web/
     * API/Response/status])
      */
    });
    var latestCheck = document.getElementById('latest-check');
    latestCheck.style.display = '';
    document.getElementById('latest-dismiss').onclick = function() {
     latestCheck.style.display = 'none';
     document.cookie = cookieText;
    }
   }
  });
 </script>
</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 9 では動作しませんでした。ボタンを右クリックしたときに flash のコンテキストメニューが表示されると動作しています。