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

2015年3月12日木曜日

2 - ol3.3ex 84b - Sphere Mollweide example 2

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

「284-ol3ex.js」
proj4.defs('ESRI:53009', '+proj=moll +lon_0=0 +x_0=0 +y_0=0 +a=6371000 ' +
 '+b=6371000 +units=m +no_defs');
/**
 * Configure the Sphere Mollweide projection object with
 * an extent, and a world extent. These are required for 
 * the Graticule.
 * ある範囲および世界全体の範囲で球状モルワイデ投影オブジェクトを
 * 設定します。これらは、グラティクル(経緯度線)に必要です。
 */
var sphereMollweideProjection = ol.proj.get('ESRI:53009');
sphereMollweideProjection.setExtent([
/** setExtent(extent)
 * Set the validity extent for this projection.
 * この投影の有効範囲を設定します。(ol3 API)
 */
  -9009954.605703328, -9009954.605703328,
  9009954.605703328, 9009954.605703328]);
sphereMollweideProjection.setWorldExtent([-179, -90, 179, 90]);
/** setWorldExtent(worldExtent) 
 * Set the world extent for this projection.
 * この東映の世界全体の範囲を設定します。
 * (ol3 API[説明は Stable Only のチェックを外すと表示])
 */
var map = new ol.Map({
 keyboardEventTarget: document,
 /** keyboardEventTarget:
  * The element to listen to keyboard events on. This
  * determines when the KeyboardPan and KeyboardZoom
  * interactions trigger. For example, if this option is set
  *  to document the keyboard interactions will always
  *  trigger. If this option is not specified, the element
  * the library listens to keyboard events on is the map
  * target (i.e. the user-provided div for the map). If this
  * is not document the target element needs to be focused
  * for key events to be emitted, requiring that the target
  * element has a tabindex attribute.
  * キーボードイベントをリッスンし続ける要素。 KeyboardPan と
  * KeyboardZoom インタラクションがトリガするときに決定します。
  * このオプションが document に設定されている場合は、キーボード
  * インタラクションが常にトリガされます。このオプションを指定しな
  * い場合、キーボードイベントをリッスンし続ける要素(ライブラリ)
  * は、マップターゲット(マップの user-provided div)です。こ
  * れが document でない場合、ターゲット要素はキーイベントが発生
  * されることに焦点が当てられる必要があり、ターゲット要素が 
  * tabindex 属性を持っていることを必要とします。
  * (ol3 API[説明は Stable Only のチェックを外すと表示])
  */
 layers: [
  new ol.layer.Vector({
   source: new ol.source.GeoJSON({
  /** ol.source.GeoJSON 
   * Static vector source in GeoJSON format
   * GeoJSON フォーマットの静的ベクタソース。(ol3 API)
   */
    projection: sphereMollweideProjection,
    // url: 'data/geojson/countries-110m.geojson'
    url: 'v3.3.0/examples/data/geojson/countries-110m.geojson'
   })
  })
 ],
 renderer: 'canvas',
 target: 'map',
 view: new ol.View({
  center: [0, 0],
  projection: sphereMollweideProjection,
  resolutions: [65536, 32768, 16384, 8192, 4096, 2048],
  zoom: 0
 })
});
var graticule = new ol.Graticule({
 map: map
 /** map:
  * Reference to an ol.Map object.
  * ol.Map オブジェクトへの参照。
  * (ol3 API[説明は Stable Only のチェックを外すと表示])
  */
});

2 - ol3.3ex 84a - Sphere Mollweide example 1

「Sphere Mollweide example (sphere-mollweide.html)」を参考に地図を表示してみます。

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





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





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



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








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











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


「284-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>Sphere Mollweide 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="span12">
     <div id="map" class="map"></div>
    </div>
   </div>
   <div class="row-fluid">
    <div class="span12">
    <h4 id="title">Sphere Mollweide example</h4>
     <p id="shortdesc">Example of a Sphere Mollweide  
      map with a Graticule component.</p>
     <div id="docs">
      <!--
      <p>See the <a href="sphere-mollweide.js" target="_blank">sphere-mollweide.js source</a> 
       to see how this is done.</p>
      -->
      <!-- ファイル修正 -->
      <p>See the <a href="284-ol3ex.js" target="_blank">284-ol3ex.js source</a> 
       to see how this is done.</p>
     </div>
     <div id="tags">graticule, Mollweide, projection, proj4js</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="http://cdnjs.cloudflare.com/ajax/libs/proj4js/2.2.1/proj4.js" type="text/javascript"></script>
  <!--
  <script src="loader.js?id=sphere-mollweide" type="text/javascript"></script>
  -->
  <!-- ファイル修正 -->  <!-- ディレクトリ修正 -->
  <script src="loader.js?id=284-ol3ex" type="text/javascript"></script>
 </body>
</html>