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

2015年12月31日木曜日

2 - ol3.12ex 146b - Render geometries to a canvas 2

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

「2146-ol3ex.js」
var canvas = document.getElementById('canvas');
var render = ol.render.toContext(canvas.getContext('2d'), {size: [100, 100]});
/** ol.render.toContext(context, opt_options)
 * Binds a Canvas Immediate API to a canvas context, 
 * to allow drawing geometries to the context's 
 * canvas.
 * The units for geometry coordinates are css pixels 
 * relative to the top left corner of the canvas 
 * element.
 * Note that ol.render.canvas.Immediate#drawAsync 
 * and ol.render.canvas.Immediate#drawFeature 
 * cannot be used.
 * コンテキストのキャンバス(canvas)にジオメトリを描画でき
 * るように、Canvas Immediate API をキャンバスコンテキス
 * ト(canvas context)にバインドします。
 * ジオメトリの座標の単位は canvas 要素の左上隅からの相対 
 * css ピクセルです。
 * ol.render.canvas.Immediate#drawAsynと
 * ol.render.canvas.Immediate#drawFeature は使用出来
 * ないことに注意してください。
 * (ol3 API[説明は Stable Only のチェックを外すと表示])
 */
/** HTMLCanvasElement.getContext()
 * The HTMLCanvasElement.getContext() method returns a 
 * drawing context on the canvas, or null if the 
 * context identifier is not supported.
 * HTMLCanvasElement.getContext()メソッドは、キャンバ
 * ス上の描画コンテキストを返すか、または コンテキスト識別
 * 子がサポートされていない場合、null を返します。
 * contextType Is a DOMString containing the context 
 * identifier defining the drawing context associated 
 * to the canvas.
 * "2d", leading to the creation of a 
 * CanvasRenderingContext2D object representing a 
 * two-dimensional rendering context.
 * contextTypeは canvas に関連する描画コンテキストを定義
 * するコンテキスト識別子を含む DOMString  です。
 * 「2D」、二次元のレンダリングコンテキストを表す
 * CanvasRenderingContext2D オブジェクトの作成につなが
 * ります。
 * (MDN[https://developer.mozilla.org/en-US/docs/Web/
 * API/HTMLCanvasElement/getContext])
 */
/** size:
 * Desired size of the canvas in css pixels. When 
 * provided, both canvas and css size will be set 
 * according to the pixelRatio. If not provided, the 
 * current canvas and css sizes will not be altered.
 * css ピクセル単位の canvas の希望のサイズ。提供される場
 * 合、canvas とcss サイズ両方とも画素比率に応じて設定され
 * ます。提供されていない場合は、現在の canvas と css のサ
 * イズは変更されません。
 * (ol3 API[説明は Stable Only のチェックを外すと表示])
 */
var fill = new ol.style.Fill({ color: 'blue' });
/** ol.style.Fill 
 * Set fill style for vector features.
 * ベクタフィーチャの塗りつぶしスタイルを設定。
 * (ol3 API[説明は Stable Only のチェックを外すと表示])
 */
var stroke = new ol.style.Stroke({ color: 'black' });
/** 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 のチェックを外すと表示])
 */
render.setFillStrokeStyle(fill, stroke);
/** setFillStrokeStyle(fillStyle, strokeStyle)
 * Set the fill and stroke style for subsequent draw 
 * operations. To clear either fill or stroke styles, 
 * pass null for the appropriate parameter.
 * 後の描画操作のための塗りと線のスタイルを設定します。塗り
 * または線のスタイルのいずれかをクリアするために、適切なパ
 * ラメータに null を渡します。
 * (ol3 API[説明は Stable Only のチェックを外すと表示])
 */
render.setImageStyle(new ol.style.Circle({
/** setImageStyle()
 * Set the image style for subsequent draw 
 * operations. Pass null to remove the image 
 * style.
 * その後のドロー操作のための画像のスタイルを設定します。
 * 画像のスタイルを削除するには null を渡します。
 * (ol3 API[説明は Stable Only のチェックを外すと表示])
 */
/** ol.style.Circle
 * Set circle style for vector features.
 * ベクタフィーチャの円のスタイルを設定。(ol3 API)
 */
 radius: 10,
 fill: fill,
 stroke: stroke
}));
render.drawLineStringGeometry(new ol.geom.LineString([[10, 10], [90, 90]]));
/**  drawLineStringGeometry(lineStringGeometry) experimental
 * Render a LineString into the canvas. Rendering is 
 * immediate and uses the current style.
 * canvas(キャンバス)に LineString をレンダリングします。
 * レンダリングは即時であり、現在のスタイルを使用します。
 * (ol3 API[説明は Stable Only のチェックを外すと表示])
 */
/** ol.geom.LineString
 * Linestring geometry.(ol3 API)
 */
render.drawPolygonGeometry(
/** drawPolygonGeometry(polygonGeometry)
 * Render a Polygon geometry into the canvas. 
 * Rendering is immediate and uses the current style.
 * キャンバス(canvas)にポリゴンジオメトリ(Polygon 
 * geometry)をレンダリングします。レンダリングは即時であ
 * り、現在のスタイルを使用します。
 * (ol3 API[説明は Stable Only のチェックを外すと表示])
 */
 new ol.geom.Polygon([[[2, 2], [98, 2], [2, 98], [2, 2]]]));
 /** ol.geom.Polygon
  * Polygon geometry.(ol3 API)
  */
render.drawPointGeometry(new ol.geom.Point([88, 88]));
/** drawPointGeometry(pointGeometry)
 * Render a Point geometry into the canvas. 
 * Rendering is immediate and uses the current style.
 * キャンバス(canvas)にポイントジオメトリ(Point 
 * geometry)をレンダリングします。レンダリングは即時であ
 * り、現在のスタイルを使用します。
 * (ol3 API[説明は Stable Only のチェックを外すと表示])
 */
/** ol.geom.Point
 * Point geometry.(ol3 API)
 */

2 - ol3.12ex 146a - Render geometries to a canvas 1

「Render geometries to a canvas (render-geometry.html)」を参考に地図を表示してみます。
説明に次のようにあります。

This example shows how to render geometries to an arbitrary canvas.
この例では、任意のキャンバスにジオメトリをレンダリングする方法を示しています。


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





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





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




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








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











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

「2146-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.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>
  <script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=fetch"></script>
  <title>Render geometries to a canvas</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">Render geometries to a canvas</h4>
     <canvas id="canvas"></canvas>
    </div>
   </div>
   <div class="row-fluid">
    <div class="span12">
     <p id="shortdesc">Example of rendering geometries to an 
      arbitrary canvas.</p>
     <div id="docs"><p>This example shows how to render 
     geometries to an arbitrary canvas.</p>
     </div>
     <div id="api-links">Related API documentation: 
      <ul class="inline">
       <li>
        <!--<a href="../apidoc/ol.geom.LineString.html" title="API documentation for ol.geom.LineString">ol.geom.LineString</a> -->
        <a href="v3.12.1/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.12.1/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.12.1/apidoc/ol.geom.Polygon.html" title="API documentation for ol.geom.Polygon">ol.geom.Polygon</a>
       </li>,
       <li>
        <!-- <a href="../apidoc/ol.render.html" title="API documentation for ol.render">ol.render</a> -->
        <a href="v3.12.1/apidoc/ol.render.html" title="API documentation for ol.render">ol.render</a>
       </li>,
       <li>
       <!-- <a href="../apidoc/ol.style.Circle.html" title="API documentation for ol.style.Circle">ol.style.Circle</a> -->
       <a href="v3.12.1/apidoc/ol.style.Circle.html" title="API documentation for ol.style.Circle">ol.style.Circle</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>
      </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=render-geometry"></script>
  -->
  <!-- ファイル修正 -->  <!-- ディレクトリ修正 -->
  <script src="loader.js?id=2146-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 のコンテキストメニューが表示されると動作しています。