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

2019年8月26日月曜日

ol5.3ex 10 - XYZ

「XYZ (xyz.html) 」を参考に地図を表示してみます。

説明に次のようにあります。

The XYZ source is used for tile data that is accessed through URLs that include a zoom level and tile grid x/y coordinates.

XYZ source は、ズームデータとタイルグリッド x/y 座標を含む URL を通してアクセスされるタイルデータに対して使用されます。


この例では、「Thunderforest(https://www.thunderforest.com/)」のサービスを使います。使い方(API の取得、価格等)についてはホームページを参照してください。

次の内容で index.js を作成します。

user@deb9-vmw:~/new-project$ vim index.js
import 'ol/ol.css';
import Map from 'ol/Map.js';
import View from 'ol/View.js';
import TileLayer from 'ol/layer/Tile.js';
import XYZ from 'ol/source/XYZ.js';
var map = new Map({
 target: 'map',
 /** 
  *  target [Map(options)]
  * The container for the map, either the element itself 
  * or the id of the element. If not specified at 
  * construction time, module:ol/Map~Map#setTarget must 
  * be called for the map to be rendered.
  * map のコンテナ、(HTML)エレメント自身、または、エレメント
  * の id。構築時に指定されていない場合、描画される map のた
  * めに module:ol/Map~Map#setTarget が呼び出されなけれ
  * ばなりません。
  * (ol5 API)
  */
 layers: [
 /** 
  * layers [Map(options)]
  * Layers. If this is not defined, a map with no layers 
  * will be rendered. Note that layers are rendered in 
  * the order supplied, so if you want, for example, a 
  * vector layer to appear on top of a tile layer, it 
  * must come after the tile layer.
  * レイヤ(layers)。これが定義されていない場合、レイヤのない
  * マップが描画されます。レイヤは提供された順番に描画されるの
  * で、例えば、ベクタレイヤがタイルレイヤの上に表示するよう望む
  * なら、タイルレイヤの後に来なければならないことに注意してくだ
  * さい。(ol5 API)
  */
  new TileLayer({
  /** 
   *  ol/layer/Tile~TileLayer 
   * For layer sources that provide pre-rendered, tiled 
   * images in grids that are organized by zoom levels for 
   * specific resolutions. 
   * プリレンダリング(事前描画)を提供するレイヤソースのため
   * の、特定の解像度でのズームレベルによって編成されているグ
   * リッドのタイルイメージ。(ol5 API)
   */
   source: new XYZ({
   /** 
    *  source [TileLayer(options)]
    * Source for this layer.
    * レイヤのソース。(ol5 API)
    */
   /** ol.source.XYZ
    * Layer source for tile data with URLs in a set XYZ 
    * format that are defined in a URL template. By 
    * default, this follows the widely-used Google grid 
    * where x 0 and y 0 are in the top left. Grids like 
    * TMS where x 0 and y 0 are in the bottom left can 
    * be used by using the {-y} placeholder in the URL 
    * template, so long as the source does not have a 
    * custom tile grid. In this case,  
    * module:ol.source.TileImage can be used with a 
    * tileUrlFunction such as:
    *
    * tileUrlFunction: function(coordinate) { 
    *  return 'http://mapserver.com/' 
    *  + coordinate[0] + '/' 
    *  + coordinate[1] + '/' 
    *  + coordinate[2] + '.png'; }
    * 
    * URL テンプレートで定義されているセット XYZ 形式の URL 
    * を持つタイルデータのレイヤソース。デフォルトでは、これは、
    * x0 と y0 が左上にある広く使用されている Google のグリッド
    * に従います。x0 と y0 が左下にある TMS のようなグリッドは、
    * ソースがカスタムタイルグリッドを持っていない限り、URL テ
    * ンプレートに {-y} プレースホルダを使用して使用することが
    * できます。この場合、ol.source.TileImage は 
    * tileUrlFunction で次のように使用できます。
    * (ol5 API)
    */
    url: 'https://{a-c}.tile.thunderforest.com/cycle/{z}/{x}/{y}.png' +
    '?apikey=Your API key from http://www.thunderforest.com/docs/apikeys/ here'
    /** 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} プレー
     * スホルダを含める必要があります。例えば 
     * subdomain{a-f}.domain.com の {?-?} テンプレートパ
     * ターンは、urls オプションでそれぞれを個別に定義する代
     * わりに、使用することができます。
     *(ol5 API)
     */
   })
  })
 ],
 view: new View({
 /** 
  *  view [Map(options)]
  * The map's view. No layer sources will be fetched 
  * unless this is specified at construction time or 
  * through module:ol/Map~Map#setView.
  * map(マップ)の view(ビュー)。これが構築時に指定されて
  * いないか、module:ol/Map~Map#setView を介さなければ、
  * 取得されるレイヤソースはありません。
  * (ol5 API)
  */
  center: [-472202, 7530279],
  /**
   *  center[new View(opt_options)]
   * The initial center for the view. The coordinate system 
   * for the center is specified with the projection option. 
   * Layer sources will not be fetched if this is not set, 
   * but the center can be set later with #setCenter.
   * view(ビュー)の初期 center(中心)値。 center の座標系
   * は、projection(投影法)オプションで指定されます。これが
   * 設定されなければレイヤソースは取得されませんが、center は 
   * #setCenter で後で設定できます。
   * (ol5 API)
   */
  zoom: 12
  /**
   *  zoom[new View(opt_options)]
   * Only used if resolution is not defined. Zoom level  
   * usedto calculate the initial resolution for the view. 
   * The initial resolution is determined using the 
   * #constrainResolution method.
   * resolution(解像度)が定義されていない場合のみ使用されま
   * す。view の初期 resolution(解像度)を計算するために使用
   * される zoom(ズーム)レベル。初期 resolution は、
   * #constrainResolution メソッドを使用して決定されます。
   * (ol5 API)
   */
 })
});
次に index.html を作成します。
user@deb9-vmw:~/new-project$ vim index.html
<!doctype html>
<html>
 <head>
  <title>XYZ</title>
  <!-- The line below is only needed for old environments like Internet Explorer and Android 4.x -->
  <script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL"></script>
 </head>
 <body>
  <div id="map" class="map"></div>
  <script src="./index.js"></script>
 </body>
</html>
npm start を実行します。

user@deb9-vmw:~/new-project$ npm start

Webブラウザのアドレス欄に

http://localhost:1234

と入力して Enter キーを押します。

ol5-ex010-01.png

2015年4月13日月曜日

2 - ol3.4ex 108b - XYZ with Retina tiles example 2

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

「2108-ol3ex.js」
var attribution = new ol.Attribution({
/** ol.Attribution
 * An attribution for a layer source.
 * レイヤソースの属性(ol3 API)
 */
 html: 'Tiles © USGS, rendered with ' +
  '<a href="http://www.maptiler.com/">MapTiler</a>'
});
var mapMinZoom = 1;
var mapMaxZoom = 15;
var mapExtent = [-112.261791, 35.983744, -112.113981, 36.132062];
var map = new ol.Map({
 target: 'map',
 layers: [
  new ol.layer.Tile({
   source: new ol.source.OSM()
   /** ol.source.OSM 
    * Layer source for the OpenStreetMap tile server.
    * OpenStreetMap タイルサーバのレイヤソース。(ol3 API)
    */
  }),
  new ol.layer.Tile({
   extent: ol.proj.transformExtent(mapExtent, 'EPSG:4326', 'EPSG:3857'),
   /** 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)
    */
   source: new ol.source.XYZ({
   /** ol.source.XYZ
    * Layer source for tile data with URLs in a set XYZ 
    * format.
    * セットXYZ形式のURLを持つタイルデータのレイヤソース。
    * (ol3 API)
    */
    attributions: [attribution],
    url: 'http://tileserver.maptiler.com/grandcanyon@2x/{z}/{x}/{y}.png',
    tilePixelRatio: 2, // THIS IS IMPORTANT
    /** tilePixelRatio
     * The pixel ratio used by the tile service. For example,
     * if the tile service advertizes 256px by 256px tiles 
     * but actually sends 512px by 512px images (for 
     * retina/hidpi devices) then tilePixelRatio should be 
     * set to 2. Default is 1.
     * タイルサービスによって使用される画素比率。例えば、タイ
     * ルサービスが 256px x 256px によるタイルを告知し、実際
     * に(retina/hidpiデバイス用)512px x 512pxで画像を送信
     * した場合、その後 tilePixelRatio を 2 に設定する必要が
     * あります。デフォルトは 1 です。
     * (ol3 API[説明は Stable Only のチェックを外すと表示])
     */
    minZoom: mapMinZoom,
    maxZoom: mapMaxZoom
   })
  })
 ],
 view: new ol.View({
  projection: 'EPSG:3857',
  center: ol.proj.transform([-112.18688965, 36.057944835],
   'EPSG:4326', 'EPSG:3857'),
  zoom: 12
 })
});
 
この地図の完成イメージは、

http://tileserver.maptiler.com/grandcanyon@2x/ol3.html

を参照してください。

2 - ol3.4ex 108a - XYZ with Retina tiles example 1

「XYZ with Retina tiles example (xyz-retina.html)」を参考に地図を表示してみます。
説明に次のようにあります。

Example of Retina/HiDPI mercator tiles (512x512px) available as XYZ.
The ol.source.XYZ must contain tilePixelRatio parameter. The tiles were prepared from a GeoTIFF file with MapTiler.

XYZ として利用できる Retina/HiDPI のメルカトルタイル(512x512px)の例。
ol.source.XYZ は tilePixelRatio パラメータが含まれている必要があります。タイルは MapTiler とともに GeoTIFF のファイルから準備しました。


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





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





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



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








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











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

「2108-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.4.0/css/ol.css" type="text/css">
  <link rel="stylesheet" href="v3.4.0/resources/bootstrap/css/bootstrap.min.css" type="text/css">
  <link rel="stylesheet" href="v3.4.0/resources/layout.css" type="text/css">
  <link rel="stylesheet" href="v3.4.0/resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
  <title>XYZ Retina tiles example</title>
 </head>
 <body>
  <!-- 
  bootstrap.min.css, bootstrap-responsive.min.css 
   Examples用 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.4.0/examples/"><img src="v3.4.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">XYZ Retina tiles example</h4>
     <p id="shortdesc">Example of Retina / HiDPI 
      mercator tiles (512x512px) available as XYZ.</p>
     <div id="docs">
      <p>The ol.source.XYZ must contain 
      <code>tilePixelRatio</code> parameter. The tiles 
      were prepared from a GeoTIFF file with 
      <a href="http://www.maptiler.com/">MapTiler</a>.</p>
      <!--
      <p>See the <a href="xyz-retina.js" target="_blank">xyz-retina.js source</a> for details on how this is done.</p>
      -->
      <!-- ファイル修正 -->
      <p>See the <a href="2108-ol3ex.js" target="_blank">2108-ol3ex.js source</a> for details on how this is done.</p>
     </div>
     <div id="tags">retina, hidpi, xyz, maptiler, @2x, 
      devicePixelRatio</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.4.0/resources/jquery.min.js" type="text/javascript"></script>
  <script src="v3.4.0/resources/example-behaviour.js" type="text/javascript"></script>
  <!--
  <script src="loader.js?id=xyz-retina" type="text/javascript"></script>
  -->
  <!-- ファイル修正 -->  <!-- ディレクトリ修正 -->
  <script src="loader.js?id=2108-ol3ex" type="text/javascript"></script>
  </body>
</html>

2015年1月22日木曜日

2 - ol3.1ex 49a - XYZ Esri EPSG:4326 tileSize 512 example 1

「XYZ Esri EPSG:4326 tileSize 512 example(xyz-esri-4326-512.html)」を参考に地図を表示してみます。

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





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





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



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








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











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


「249-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.1.1/css/ol.css" type="text/css">
  <link rel="stylesheet" href="v3.1.1/resources/bootstrap/css/bootstrap.min.css" type="text/css">
  <link rel="stylesheet" href="v3.1.1/resources/layout.css" type="text/css">
  <link rel="stylesheet" href="v3.1.1/resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
  <title>XYZ Esri EPSG:4326 tileSize 512 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.1.1/examples/"><img src="v3.1.1/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">XYZ Esri EPSG:4326 tileSize 512 example</h4>
     <p id="shortdesc">Example of a XYZ source in EPSG:4326 using Esri 512x512 tiles.</p>
     <div id="docs">
      <!--
      See the <a href="xyz-esri-4326-512.js" target="_blank">xyz-esri-4326-512.js source</a> to see how this is done.</p>
      -->
      <!-- ファイル修正 -->
      See the <a href="249-ol3ex.js" target="_blank">249-ol3ex.js source</a> to see how this is done.</p>
     </div>
     <div id="tags">xyz, esri, tilesize, custom projection</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.1.1/resources/jquery.min.js" type="text/javascript"></script>
  <script src="v3.1.1/resources/example-behaviour.js" type="text/javascript"></script>
  <!--
  <script src="loader.js?id=xyz-esri-4326-512" type="text/javascript"></script>
  -->
  <!-- ファイル修正 -->  <!-- ディレクトリ修正 -->
  <script src="loader.js?id=249-ol3ex" type="text/javascript"></script>
 </body>
</html>

2014年9月25日木曜日

2 - ol3ex 6b - XYZ Esri example 2

「xyz-esri.js(206-ol3ex.js)」は、地図を表示するのに必要な javascript です。「206-ol3ex.js」
var attribution = new ol.Attribution({
 html: 'Tiles © <a href="http://services.arcgisonline.com/ArcGIS/' +
     'rest/services/World_Topo_Map/MapServer">ArcGIS</a>'
});
var map = new ol.Map({
 target: 'map',
 layers: [
  new ol.layer.Tile({
   source: new ol.source.XYZ({
   attributions: [attribution],
   url: 'http://server.arcgisonline.com/ArcGIS/rest/services/' +
      'World_Topo_Map/MapServer/tile/{z}/{y}/{x}'
   })
  })
 ],
 view: new ol.View2D({
//center: ol.proj.transform([-121.1, 47.5], 'EPSG:4326', 'EPSG:3857'),
  center: ol.proj.transform([139.42, 35.68], 'EPSG:4326', 'EPSG:3857'),
  /** ol.proj.transform(coordinate, source, destination)
   * Transforms a coordinate from source projection to 
   * destination projection. This returns a new coordinate 
   * (and does not modify the original).
   * ソース投影から変換先投影に座標変換します。これは、新しい座標
   * を返します(オリジナルを変更しません)。(ol3 API)
   */
//zoom: 7
  zoom: 10
 })
});

2 - ol3ex 6a - XYZ Esri example 1

「XYZ Esri example(xyz-esri.html)」を参考に地図を表示してみます。「ArcGIS」のマップサービス(http://www.arcgis.com/features/index.html)を使用しています。地図上の「ArcGIS」のリンク「World_Topo_Map(http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer)」に地図の説明があります。

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





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




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



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








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











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


「206-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>XYZ Esri example</title>
 </head>
 <body>

  <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="span12">
     <h4 id="title">XYZ Esri example</h4>
     <p id="shortdesc">Example of a XYZ source using Esri tiles.</p>
     <div id="docs">
<!--
      <p>See the <a href="xyz-esri.js" target="_blank">xyz-esri.js source</a> for details on how this is done.</p>
-->
       <!-- ファイル修正 -->
      <p>See the <a href="206-ol3ex.js" target="_blank">206-ol3ex.js source</a> for details on how this is done.</p>
     </div>
     <div id="tags">xyz, esri</div>
    </div>
   </div>
  </div>
<!--
  <script src="jquery.min.js" type="text/javascript"></script>
  <script src="../resources/example-behaviour.js" type="text/javascript"></script>
-->
  <!-- ディレクトリ修正 -->
  <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=xyz-esri" type="text/javascript"></script>
-->
  <!-- ファイル修正 -->  <!-- ディレクトリ修正 -->
  <script src="loader.js?id=206-ol3ex" type="text/javascript"></script>
 </body>
</html>

2014年9月24日水曜日

2 - ol3ex 5b - XYZ example 2

「xyz.js(205-ol3ex.js)」は、地図を表示するのに必要な javascript です。
「205-ol3ex.js」
var attribution = new ol.Attribution({
/** ol.Attribution
 * An attribution for a layer source.
 * レイヤソースの属性(ol3 API)
 */
/**
 * html: 'Tiles &copy; <a href="http://maps.nls.uk/townplans/glasgow_1.html">' +
 *     'National Library of Scotland</a>'
 */
 html: "Tiles &copy; <a href='http://portal.cyberjapan.jp/help/termsofuse.html' target='_blank'>" +
      "国土地理院</a>"
});
var map = new ol.Map({
 target: '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()
  * デフォルトでは、マップに含まコントロールのセット。
  * 特に設定しない限り、これは、以下の各コントロールの
  * インスタンスを含むコレクションを返します。(ol3 API)
  * ol.control.Zoom, ol.control.Rotate, ol.control.Attribution
  */
  attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
  /** @type 
   * 値のタイプ(型)の説明 - 式などで表示
   * (@use JSDoc[http://usejsdoc.org/]より)
   */
   collapsible: false
  })
 }),
 layers: [
/**
 *new ol.layer.Tile({
 * source: new ol.source.OSM({
 *  attributions: [
 *   new ol.Attribution({
 *    html: 'Tiles &copy; <a href="http://www.opencyclemap.org/">' +
 *        'OpenCycleMap</a>'
 *   }),
 *   ol.source.OSM.DATA_ATTRIBUTION // OpenStreetMap の DATA Attribution を取得
 *  ],
 *  url: 'http://{a-c}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png'
 * })
 *}),
 */
  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.XYZ({
   /** ol.source.XYZ
    * Layer source for tile data with URLs in a set XYZ 
    * format.
    * XYZ フォーマットの URL をともなったタイルデータのレイヤ
    * ソース。(ol3 API)
    */
    attributions: [attribution],
//  url: 'http://geo.nls.uk/maps/towns/glasgow1857/{z}/{x}/{-y}.png'
    url: 'http://cyberjapandata.gsi.go.jp/xyz/std/{z}/{x}/{y}.png'
   })  })
 ],
 view: new ol.View({
// center: [-472202, 7530279],
   center: [15520720, 4257706], // EPSG:3857 の値
// zoom: 12
   zoom: 10
 })
});


属性(attribution)が途中までしか表示されませんでした。
v3.0.0/css/ol.css の 「.ol-attribution ul」 のスタイルを次のように修正しました。
(全て、1行で記述されていますが、見やすいように直してあります。)
---
.ol-attribution ul{
 margin:0;
 padding:0 .5em;
 /* font-size:.7rem; */
 font-size:.7em;
 line-height:1.375em;
 color:#000;
 text-shadow:0 0 2px #fff;
 /* max-width:calc(100% - 3.6em); */
 max-width:calc(100%)
}
---



2 - ol3ex 5a - XYZ example 1

「XYZ example(xyz.html)」を参考に地図を表示してみます。「地理院地図」(http://portal.cyberjapan.jp/site/mapuse4/)の「技術情報」リンクをクリックして表示した「地理院タイルを用いた開発(http://portal.cyberjapan.jp/help/development.html)」に「地理院タイル仕様」と「地理院タイル一覧」があります。このうちの「標準地図」と「電子国土基本図(オルソ画像)」を使ってみます。

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





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





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



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









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









f 「xyz.html」の内容をコピーして「205-ol3ex.html」に貼り付け、修正します。

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



「205-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>XYZ example</title>
 </head>
 <body>

  <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="span12">
     <h4 id="title">XYZ example</h4>
     <p id="shortdesc">Example of a XYZ source.</p>
     <div id="docs">
<!--
      <p>See the <a href="xyz.js" target="_blank">xyz.js source</a> for details on how this is done.</p>
-->
       <!-- ファイル修正 -->
      <p>See the <a href="205-ol3ex.js" target="_blank">205-ol3ex.js source</a> for details on how this is done.</p>
     </div>
     <div id="tags">xyz</div>
    </div>
   </div>
  </div>
<!--
  <script src="jquery.min.js" type="text/javascript"></script>
  <script src="../resources/example-behaviour.js" type="text/javascript"></script>
-->
  <!-- ディレクトリ修正 -->
  <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=xyz" type="text/javascript"></script>
-->
  <!-- ファイル修正 -->  <!-- ディレクトリ修正 -->
  <script src="loader.js?id=205-ol3ex" type="text/javascript"></script>
 </body>
</html>

2014年7月3日木曜日

2 - ol3-beta.5ex 7b - XYZ Esri example 2

「xyz-esri.js(207-ol3ex.js)」は、地図を表示するのに必要な javascript です。
「207-ol3ex.js」
var attribution = new ol.Attribution({
 html: 'Tiles © <a href="http://services.arcgisonline.com/ArcGIS/' +
     'rest/services/World_Topo_Map/MapServer">ArcGIS</a>'
});
var map = new ol.Map({
 target: 'map',
 layers: [
  new ol.layer.Tile({
   source: new ol.source.XYZ({
   attributions: [attribution],
   url: 'http://server.arcgisonline.com/ArcGIS/rest/services/' +
      'World_Topo_Map/MapServer/tile/{z}/{y}/{x}'
   })
  })
 ],
 view: new ol.View2D({
//center: ol.proj.transform([-121.1, 47.5], 'EPSG:4326', 'EPSG:3857'),
  center: ol.proj.transform([139.42, 35.68], 'EPSG:4326', 'EPSG:3857'),
//zoom: 7
  zoom: 10
 })
});

2 - ol3-beta.5ex 7a - XYZ Esri example 1

「XYZ Esri example(xyz-esri.html)」を参考に地図を表示してみます。
「ArcGIS」のマップサービス(http://www.arcgis.com/features/index.html)を使用しています。地図上の「ArcGIS」のリンク「World_Topo_Map(http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer)」に地図の説明があります。

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





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




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



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








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











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


「207-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-beta.5/css/ol.css" type="text/css">
  <link rel="stylesheet" href="v3.0.0-beta.5/resources/bootstrap/css/bootstrap.min.css" type="text/css">
  <link rel="stylesheet" href="v3.0.0-beta.5/resources/layout.css" type="text/css">
  <link rel="stylesheet" href="v3.0.0-beta.5/resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
  <title>XYZ Esri example</title>
 </head>
 <body>

  <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-beta.5/examples/"><img src="v3.0.0-beta.5/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">XYZ Esri example</h4>
     <p id="shortdesc">Example of a XYZ source using Esri tiles.</p>
     <div id="docs">
<!--
      <p>See the <a href="xyz-esri.js" target="_blank">xyz-esri.js source</a> for details on how this is done.</p>
-->
       <!-- ファイル修正 -->
      <p>See the <a href="207-ol3ex.js" target="_blank">207-ol3ex.js source</a> for details on how this is done.</p>
     </div>
     <div id="tags">xyz, esri</div>
    </div>
   </div>
  </div>
<!--
  <script src="jquery.min.js" type="text/javascript"></script>
  <script src="../resources/example-behaviour.js" type="text/javascript"></script>
-->
  <!-- ディレクトリ修正 -->
  <script src="v3.0.0-beta.5/examples/jquery.min.js" type="text/javascript"></script>
  <script src="v3.0.0-beta.5/resources/example-behaviour.js" type="text/javascript"></script>
<!--
  <script src="loader.js?id=xyz-esri" type="text/javascript"></script>
-->
  <!-- ファイル修正 -->  <!-- ディレクトリ修正 -->
  <script src="loader.js?id=207-ol3ex" type="text/javascript"></script>
 </body>
</html>

2 - ol3-beta.5ex 6b - XYZ example 2

「xyz.js(206-ol3ex.js)」は、地図を表示するのに必要な javascript です。

「206-ol3ex.js」
var attribution = new ol.Attribution({
/*
 * html: 'Tiles © <a href="http://maps.nls.uk/townplans/glasgow_1.html">' +
 *     'National Library of Scotland</a>'
 */
 html: "<a href='http://portal.cyberjapan.jp/help/termsofuse.html' target='_blank'>" +
      "国土地理院</a>"
});
var map = new ol.Map({
 target: 'map',
 layers: [
/*
 *new ol.layer.Tile({
 * source: new ol.source.OSM({
 *  attributions: [
 *   new ol.Attribution({
 *    html: 'Tiles © <a href="http://www.opencyclemap.org/">' +
 *        'OpenCycleMap</a>'
 *   }),
 *   ol.source.OSM.DATA_ATTRIBUTION // OpenStreetMap の DATA Attribution を取得
 *  ],
 *  url: 'http://{a-c}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png'
 * })
 *}),
 */
  new ol.layer.Tile({
   source: new ol.source.XYZ({
    attributions: [attribution],
//  url: 'http://geo.nls.uk/maps/towns/glasgow1857/{z}/{x}/{-y}.png'
    url: 'http://cyberjapandata.gsi.go.jp/xyz/std/{z}/{x}/{y}.png'
   })  })
 ],
 view: new ol.View2D({
// center: [-472202, 7530279],
   center: [15520720, 4257706], // EPSG:3857 の値
// zoom: 12
   zoom: 10
 })
});


2 - ol3-beta.5ex 6a - XYZ example 1

「XYZ example(xyz.html)」を参考に地図を表示してみます。
「地理院地図」(http://portal.cyberjapan.jp/site/mapuse4/)の「技術情報」リンクをクリックして表示した「地理院タイルを用いた開発(http://portal.cyberjapan.jp/help/development.html)」に「地理院タイル仕様」と「地理院タイル一覧」があります。このうちの「標準地図」と「電子国土基本図(オルソ画像)」を使ってみます。

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





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





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



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









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









f 「xyz.html」の内容をコピーして「206-ol3ex.html」に貼り付け、修正します。

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

「206-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-beta.5/css/ol.css" type="text/css">
  <link rel="stylesheet" href="v3.0.0-beta.5/resources/bootstrap/css/bootstrap.min.css" type="text/css">
  <link rel="stylesheet" href="v3.0.0-beta.5/resources/layout.css" type="text/css">
  <link rel="stylesheet" href="v3.0.0-beta.5/resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
  <title>XYZ example</title>
 </head>
 <body>

  <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-beta.5/examples/"><img src="v3.0.0-beta.5/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">XYZ example</h4>
     <p id="shortdesc">Example of a XYZ source.</p>
     <div id="docs">
<!--
      <p>See the <a href="xyz.js" target="_blank">xyz.js source</a> for details on how this is done.</p>
-->
       <!-- ファイル修正 -->
      <p>See the <a href="206-ol3ex.js" target="_blank">206-ol3ex.js source</a> for details on how this is done.</p>
     </div>
     <div id="tags">xyz</div>
    </div>
   </div>
  </div>
<!--
  <script src="jquery.min.js" type="text/javascript"></script>
  <script src="../resources/example-behaviour.js" type="text/javascript"></script>
-->
  <!-- ディレクトリ修正 -->
  <script src="v3.0.0-beta.5/examples/jquery.min.js" type="text/javascript"></script>
  <script src="v3.0.0-beta.5/resources/example-behaviour.js" type="text/javascript"></script>
<!--
  <script src="loader.js?id=xyz" type="text/javascript"></script>
-->
  <!-- ファイル修正 -->  <!-- ディレクトリ修正 -->
  <script src="loader.js?id=206-ol3ex" type="text/javascript"></script>
 </body>
</html>