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

2015年3月12日木曜日

2 - ol3.3ex 85b - Tissot indicatrix example 2

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

「285-ol3ex.js」
var vectorLayer4326 = new ol.layer.Vector({
 /*: ol.source.Vector 
  * Provides a source of features for vector layers.
  * ベクタレイヤのフィーチャのソースを提供します。(ol3 API)
  */
 source: new ol.source.Vector()
});
var vectorLayer3857 = new ol.layer.Vector({
 source: new ol.source.Vector()
});
var map4326 = new ol.Map({
 layers: [
  new ol.layer.Tile({
   source: new ol.source.TileWMS({
   /** ol.source.TileWMS
    * Layer source for tile data from WMS servers.
    * WMS サーバからのタイルデータのレイヤソース。
    * (ol3 API)
    */
    url: 'http://demo.boundlessgeo.com/geoserver/wms',
    params: {
     'LAYERS': 'ne:NE1_HR_LC_SR_W_DR'
    }
   })
  }),
  vectorLayer4326
 ],
 renderer: 'canvas',
 target: 'map4326',
 view: new ol.View({
  projection: 'EPSG:4326',
  center: [0, 0],
  zoom: 2
 })
});
var map3857 = new ol.Map({
 layers: [
  new ol.layer.Tile({
   source: new ol.source.TileWMS({
    url: 'http://demo.boundlessgeo.com/geoserver/wms',
    params: {
     'LAYERS': 'ne:NE1_HR_LC_SR_W_DR'
    }
   })
  }),
  vectorLayer3857
 ],
 renderer: 'canvas',
 target: 'map3857',
 view: new ol.View({
  center: [0, 0],
  zoom: 2
 })
});
var wgs84Sphere = new ol.Sphere(6378137);
/** ol.Sphere
 * Class to create objects that can be used with 
 * ol.geom.Polygon.circular.
 * For example to create a sphere whose radius is equal 
 * to the semi-major axis of the WGS84 ellipsoid:
 * ol.geom.Polygon.circular が使用できるオブジェクトを作成
 * するクラス。
 * 例えば、WGS84 楕円の半長径に等しい半径の球体を作成します。
 * (ol3 API)
 */
var radius = 800000;
var x, y;
for (x = -180; x < 180; x += 30) {
 for (y = -90; y < 90; y += 30) {
  var circle4326 = ol.geom.Polygon.circular(wgs84Sphere, [x, y], radius, 64);
  /** ol.geom.Polygon.circular(sphere, center, radius, opt_n)
   * Create an approximation of a circle on the surface 
   * of a sphere.
   * 球の表面上の円の近似値を作成します。(ol3 API)
   */
  var circle3857 = circle4326.clone().transform('EPSG:4326', 'EPSG:3857');
  /** clone()
   * Make a complete copy of the geometry.
   * ジオメトリの完全なコピーを作成します。(ol3 API)
   */
  vectorLayer4326.getSource().addFeature(new ol.Feature(circle4326));
  /** getSource()
   * Return: Source.(ol3 API)
   */
  /** addFeature(feature)
   * Add a single feature to the source. If you want 
   * to add a batch of features at once, call 
   * source.addFeatures() instead.
   * ソースに一つのフィーチャを追加します。すぐにフィーチャの
   * バッチを追加したい場合は、代わりに source.addFeatures()
   * を呼び出します。(ol3 API)
   */
  /** 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)
   */
  vectorLayer3857.getSource().addFeature(new ol.Feature(circle3857));
 }
}

2 - ol3.3ex 85a - Tissot indicatrix example 1

「Tissot indicatrix example (tissot.html)」を参考に地図を表示してみます。

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





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





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



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








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











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


「285-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.3.0/css/ol.css" type="text/css">
  <link rel="stylesheet" href="v3.3.0/resources/bootstrap/css/bootstrap.min.css" type="text/css">
  <link rel="stylesheet" href="v3.3.0/resources/layout.css" type="text/css">
  <link rel="stylesheet" href="v3.3.0/resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
  <title>Tissot indicatrix 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.3.0/examples/"><img src="v3.3.0/resources/logo.png"> OpenLayers 3 Examples</a>
    </div>
   </div>
  </div>
  <div class="container-fluid">
   <div class="row-fluid">
    <div class="span6">
     <h4>EPSG:4326</h4>
     <div id="map4326" class="map"></div>
    </div>
    <div class="span6">
     <h4>EPSG:3857</h4>
     <div id="map3857" class="map"></div>
    </div>
   </div>
   <div class="row-fluid">
    <div class="span12">
    <h4 id="title">Tissot indicatrix example</h4>
     <p id="shortdesc">Example of 
     <a href="http://en.wikipedia.org/wiki/ Tissot's_indicatrix">
     Tissot indicatrix</a> maps. 
     The map on the left is an EPSG:4326 map. 
     The one on the left is EPSG:3857. </p>
     <div id="docs">
      <!--
      <p>See the <a href="tissot.js" target="_blank">tissot.js source</a> 
       to see how this is done.</p>
      -->
      <!-- ファイル修正 -->
      <p>See the <a href="285-ol3ex.js" target="_blank">285-ol3ex.js source</a> 
       to see how this is done.</p>
     </div>
     <div id="tags">tissot, circle</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.3.0/resources/jquery.min.js" type="text/javascript"></script>
  <script src="v3.3.0/resources/example-behaviour.js" type="text/javascript"></script>
  <!--
  <script src="loader.js?id=tissot" type="text/javascript"></script>
  -->
  <!-- ファイル修正 -->  <!-- ディレクトリ修正 -->
  <script src="loader.js?id=285-ol3ex" type="text/javascript"></script>
 </body>
</html>