ラベル js ファイル の投稿を表示しています。 すべての投稿を表示
ラベル js ファイル の投稿を表示しています。 すべての投稿を表示

2015年11月30日月曜日

2 - ol3.11ex 138b - Image reprojection example 2

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

「2138-ol3ex.js」
proj4.defs('EPSG:27700', '+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 ' +
 '+x_0=400000 +y_0=-100000 +ellps=airy ' +
 '+towgs84=446.448,-125.157,542.06,0.15,0.247,0.842,-20.489 ' +
 '+units=m +no_defs');
var imageExtent = [0, 0, 700000, 1300000];

var map = new ol.Map({
 layers: [
  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.MapQuest({layer: 'osm'})
   /** ol.source.MapQuest
    * Layer source for the MapQuest tile server.
    * MapQuest タイルサーバのレイヤソース。(ol3 API
    * 2 - ol3ex 23b - MapQuest example 2 参照)
    */
  }),
  new ol.layer.Image({
  /** ol.layer.Image
   * Server-rendered images that are available for arbitrary 
   * extents and resolutions. 
   * 任意の範囲と解像度で利用可能な server-rendered イメージ。
   * (ol3 API)
   */
   source: new ol.source.ImageStatic({
   /** source.ImageStatic
    * A layer source for displaying a single, static image.
    * 単一で静的(東映データが付加されていない)画像の表示のため
    * のレイヤソース。(ol3 API)
    */
    url: 'http://upload.wikimedia.org/wikipedia/commons/thumb/1/18/' +
     'British_National_Grid.svg/2000px-British_National_Grid.svg.png',
    crossOrigin: '',
    /** crossOrigin
     * The crossOrigin attribute for loaded images. Note 
     * that you must provide a crossOrigin value if you 
     * are using the WebGL renderer or if you want to 
     * access pixel data with the Canvas renderer. See 
     * https://developer.mozilla.org/en-US/docs/Web/HTML/
     * CORS_enabled_image for more detail.
     * ロードされたイメージの crossOrigin属性。WebGLのレンダ
     * ラーを使用している場合、または、キャンバスレンダラでピ
     * クセルデータにアクセスする場合、crossOrigin 値を提供な
     * ければならないことに注意してください。詳細は 
     * https://developer.mozilla.org/en-US/docs/Web/HTML/
     * CORS_enabled_image を参照してください。(ol3 API)
     */
    projection: 'EPSG:27700',
    imageExtent: imageExtent
    /** imageExtent
     * Extent of the image in map coordinates. This is the 
     * [left, bottom, right, top] map coordinates of your 
     * image. Required.
     * マップ座標の画像の範囲が調整。これは、イメージのマップ座標
     * [左、下、右、上]です。 必須。(ol3 API)
     */
   })
  })
 ],
 renderer: common.getRendererFromQueryString(),
// 'common.js' により URL にある renderer を返します
 target: 'map',
 view: new ol.View({
  center: ol.proj.transform(ol.extent.getCenter(imageExtent),
   'EPSG:27700', '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)
   */
  /** ol.extent.getCenter(extent)
   * Get the center coordinate of an extent.
   * 範囲の中心座標を取得します。(ol3 API)
   */
  zoom: 4
 })
});

2 - ol3.11ex 137b - OpenStreetMap reprojection example 2

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

「2137-ol3ex.js」
var map = new ol.Map({
 layers: [
  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.OSM()
   /** ol.source.OSM 
    * Layer source for the OpenStreetMap tile server.
    * OpenStreetMap タイルサーバのレイヤソース。(ol3 API)
    */
  })
 ],
 renderer: common.getRendererFromQueryString(),
// 'common.js' により URL にある renderer を返します
 target: 'map',
 view: new ol.View({
  projection: 'EPSG:4326',
  center: [0, 0],
  zoom: 1
 })
});

2014年11月30日日曜日

2 - ol3ex 32b - Timezones in KML 2

「kml-timezones.js(232-ol3ex.js)」は、マップを表示するための JavaScript ファイルです。
timezones.kml の内容は、次のようになっています。
「timezones.kml」
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.2">
<Document>
 <Style id="hidelist"><ListStyle><listItemType>checkHideChildren</listItemType><bgColor>00ffffff</bgColor><maxSnippetLines>0</maxSnippetLines></ListStyle></Style>
 <Style id="nStylem1200"><LineStyle><color>4cffffff</color><width>1.0</width></LineStyle><PolyStyle><color>d261d6cd</color></PolyStyle></Style>
  <Style id="nStylem1100"><LineStyle><color>4cffffff</color><width>1.0</width></LineStyle><PolyStyle><color>d25bb85f</color></PolyStyle></Style>
---
 <Style id="hStylem1200"><LineStyle><color>c0ffffff</color><width>1.0</width></LineStyle><PolyStyle><color>da61d6cd</color></PolyStyle></Style>
 <Style id="hStylem1100"><LineStyle><color>c0ffffff</color><width>1.0</width></LineStyle><PolyStyle><color>da5bb85f</color></PolyStyle></Style>
---
 <StyleMap id="khStylem1200"><Pair><key>normal</key><styleUrl>#nStylem1200</styleUrl></Pair><Pair><key>highlight</key><styleUrl>#hStylem1200</styleUrl></Pair></StyleMap>
 <StyleMap id="khStylem1100"><Pair><key>normal</key><styleUrl>#nStylem1100</styleUrl></Pair><Pair><key>highlight</key><styleUrl>#hStylem1100</styleUrl></Pair></StyleMap>
---
 <styleUrl>#hidelist</styleUrl>
 <Placemark>
  <name>GMT -12:00</name>
  <description><![CDATA[<div style="width:300px;height:50px;"  id="clock" ></div>
   <script language="JavaScript">
    var int=self.setInterval("tick()",50);
    function tick(){
     document.getElementById("clock").innerHTML=calc(-12);
    }
    function calc(offset) {
     d = new Date();
     utc = d.getTime() + (d.getTimezoneOffset() * 60000);
     nd = new Date(utc + (3600000*offset));
     return nd.toLocaleString();
    }
   </script>
  ]]></description>
  <styleUrl>#khStylem1200</styleUrl>
  <MultiGeometry>
   <Polygon>
    <outerBoundaryIs>
     <LinearRing>
      <coordinates>
       -179.0623,-89.90000000000001,0 -180,-89.90000000000001,0 -180,-86.5,0 -180,-81.49999,0 -180,-76.5,0 -180,-71.5,0 -180,-66.5,0 -180,-61.5,0 -180,-56.5,0 -180,-51.50000000000001,0 -176.2216,-48.22535,0 -172.5,-45,0 -172.4998,-50,0 -172.4996,-55.00000000000001,0 -172.4995,-60.00000000000001,0 -172.4993,-65,0 -172.4991,-70,0 -172.4989,-75,0 -172.4987,-80,0 -172.4986,-83.3,0 -172.4984,-88.3,0 -172.4984,-89.90000000000001,0 -173.4361,-89.90000000000001,0 -174.3738,-89.90000000000001,0 -175.3115,-89.90000000000001,0 -176.2492,-89.90000000000001,0 -177.1869,-89.90000000000001,0 -178.1246,-89.90000000000001,0 -179.0623,-89.90000000000001,0 
      </coordinates>
     </LinearRing>
    </outerBoundaryIs>
    <tessellate>1</tessellate>
   </Polygon>
   <Polygon>
    <outerBoundaryIs>
     <LinearRing>
      <coordinates>
       -172.509,74.89999,0 -172.509,70.23302,0 -175.7817,72.31562,0 -180,75,0 -180,79.90000000000001,0 -180,84.90001,0 -180,89.90000000000001,0 -179.0636,89.90000000000001,0 -178.1273,89.90000000000001,0 -177.1909,89.90000000000001,0 -176.2545,89.90000000000001,0 -175.3181,89.90000000000001,0 -174.3818,89.90000000000001,0 -173.4454,89.90000000000001,0 -172.509,89.90000000000001,0 -172.509,84.90001,0 -172.509,79.90000000000001,0 -172.509,74.89999,0
      </coordinates>
     </LinearRing>
    </outerBoundaryIs>
    <tessellate>1</tessellate>
   </Polygon>
  </MultiGeometry>
 </Placemark>
 <Placemark>
  <name>GMT -11:00</name>
---
「232-ol3ex.js」
var styleFunction = function(feature, resolution) {
 var offset = 0;
 var name = feature.get('name'); // e.g. GMT -08:30
 /** get(key)
  * Gets a value.
  * (ol3 API[説明は Stable Only のチェックを外すと表示])
  */
 var match = name.match(/([\-+]\d{2}):(\d{2})$/);
 /**
  * /([\-+]\d{2}):(\d{2})$/
  * [\-+] --- - または +
  * \d --- 数値
  * \d{2} --- 2個の数値
  * $ --- 行の最後
  * (-> 00:00 という文字列) 
  */
 if (match) {
  var hours = parseInt(match[1], 10);
  /** parseInt(string, radix)
   * str: 文字列, radix: 基数(進法)
   * 文字列の引数をパースし、指定された基数の整数を返します。
   * (MDN[https://developer.mozilla.org/ja/docs/Web/
   * JavaScript/Reference/Global_Objects/parseInt])
   */
  /** String.prototype.match()
   * 正規表現 に対する 文字列 のマッチングの際に、そのマッチ
   * 結果を得るために使われます。
   * (MDN[https://developer.mozilla.org/ja/docs/Web/
   * JavaScript/Reference/Global_Objects/String/match])
   */
  var minutes = parseInt(match[2], 10);
  offset = 60 * hours + minutes;
 }
 var date = new Date();
 /** Date
  * 日付や時刻を扱うことが可能な、JavaScript の Date 
  * インスタンスを生成します。
  * (MDN[https://developer.mozilla.org/ja/docs/Web/
  * JavaScript/Reference/Global_Objects/Date])
  */
 var local = new Date(date.getTime() +
  (date.getTimezoneOffset() + offset) * 60000);
 // offset from local noon (in hours)
 /** Date.prototype.getTime()
  * ユニバーサル時間に従い、指定された日付の時刻に対応する数
  * 値を返します。
  * GetTime メソッドによって返される値は、1970 年 1 月 1 日 
  * 00:00:00 UTC からの経過ミリ秒です。このメソッドは、日付
  * と時刻を別の Date オブジェクトに割り当てるために使用できま
  * す。
  * (MDN[https://developer.mozilla.org/ja/docs/Web/
  * JavaScript/Reference/Global_Objects/Date/getTime])
  */
 /** Date.prototype.getTimezoneOffset()
  * UTCと現在のロケール時間との差を分単位で返します。
  * (MDN[https://developer.mozilla.org/ja/docs/Web/
  * JavaScript/Reference/Global_Objects/Date/
  * getTimezoneOffset])
  */
 var delta = Math.abs(12 - local.getHours() + (local.getMinutes() / 60));
  /** Math.abs()
   * 引数として与えた数の絶対値を返します。
   * (MDN[https://developer.mozilla.org/ja/docs/Web/
   * JavaScript/Reference/Global_Objects/Math/abs])
   */
 /** Date.prototype.getHours()
  * 地方時に基づき、指定された日時の「時」を返します。
  * (MDN[https://developer.mozilla.org/ja/docs/Web/
  * JavaScript/Reference/Global_Objects/Date/getHours])
  */
 /** Date.prototype.getMinutes()
  * ローカル時刻の「分」(minutes)を返します。
  * (MDN[https://developer.mozilla.org/ja/docs/Web/
  * JavaScript/Reference/Global_Objects/Date/getMinutes])
  */
 if (delta > 12) {
  delta = 24 - delta;
 }
 var opacity = 0.75 * (1 - delta / 12);
 return [new ol.style.Style({
 /** ol.style.Style 
  * Base class for vector feature rendering styles.
  * ベクタフィーチャがスタイルを描画するための基本クラス。
  * (ol3 API)
  */
  fill: new ol.style.Fill({
  /** ol.style.Fill 
   * Set fill style for vector features.
   * ベクタフィーチャの塗りつぶしスタイルを設定。(ol3 API)
   */
   color: [0xff, 0xff, 0x33, opacity]
  }),
  stroke: new ol.style.Stroke({
  /** 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)
   */
   color: '#ffffff'
  })
 })];
};
var vector = new ol.layer.Vector({
/** ol.layer.Vector
 * Vector data that is rendered client-side.
 * クライアント側で描画されるベクタデータ。(ol3 API)
 */
 source: new ol.source.KML({
 /** ol.source.KML 
  * Static vector source in KML format
  * KML フォーマットの静的ベクタソース(0l3 API)
  */
  extractStyles: false,
  projection: 'EPSG:3857',
  // url: 'data/kml/timezones.kml'
  url: 'v3.0.0/examples/data/kml/timezones.kml' // 修正
 }),
 style: styleFunction
});
var raster = 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.Stamen({
 /** ol.source.Stamen
  * Layer source for the Stamen tile server.
  * Stamen タイルサーバのレイヤソース。(ol3 API)
  * (2 - ol3ex 24b - Stamen example 2 参照)
  */
  layer: 'toner'
 })
});
var map = new ol.Map({
 layers: [raster, vector],
 target: 'map',
 view: new ol.View({
  center: [0, 0],
  zoom: 2
 })
});
var info = $('#info');
info.tooltip({
/** Tooltips tooltip.js
 * Inspired by the excellent jQuery.tipsy plugin written 
 * by Jason Frame; Tooltips are an updated version, 
 * which don't rely on images, use CSS3 for animations, 
 * and data-attributes for local title storage.
 * Jason Frame によって書かれた優れたjQuery.tipsyプラグイン
 * に触発されました。Tooltips は、更新されたバージョンで、画像
 * に依存しない、アニメーションに CSS3 を使用し、ローカルタイト
 * ル·ストレージのためのデータの属性です。
 * (Bootstrap[http://getbootstrap.com/javascript/
 * #tooltips])
 * カーソルを何かの項目に合わせたとき、その項目に覆いかぶさるよう
 * な形で小さな枠が出現し、その枠内には選択された項目に関する補足
 * 情報が表示される。
 * (ツールチップ[http://ja.wikipedia.org/wiki/
 * %E3%83%84%E3%83%BC%E3%83%AB%E3%83%81%E3%83%83%E3%83%97])
 */
 animation: false,
 /** animation
  * Apply a CSS fade transition to the tooltip
  * ツールチップにCSSのフェードトランジション(遷移)を適用しま
  * す。
  */
 trigger: 'manual'
 /** trigger
  * How tooltip is triggered - click | hover |
  *  focus | manual. You may pass multiple triggers; 
  * separate them with a space.
  * ツールチップがトリガされる方法 - click | hover |
  *  focus | manual。複数のトリガを設定するには、スペースで
  * 分割。
  */
});
var displayFeatureInfo = function(pixel) {
 info.css({
 /** .css()
  * Get the computed style properties for the first element 
  * in the set of matched elements.
  * マッチした要素のセットの最初の要素の計算されたスタイルプロ
  * パティを取得します。
  * (jQuery[http://api.jquery.com/css/])
  */ 
  left: pixel[0] + 'px',
  top: (pixel[1] - 15) + 'px'
 });
 var feature = map.forEachFeatureAtPixel(pixel, function(feature, layer) {
 /** forEachFeatureAtPixel
  * Detect features that intersect a pixel on the viewport, 
  * and execute a callback with each intersecting feature. 
  * Layers included in the detection can be configured 
  * through opt_layerFilter. Feature overlays will always 
  * be included in the detection.
  * ビューポート上のピクセルと交差するフィーチャを検出し、
  * 各交差するフィーチャとコールバックを実行します。
  * 検出に含まれるレイヤが opt_layerFilter を通じて
  * 設定することができます。フィーチャーオーバーレイは
  * 常に検出に含まれます。(ol3 API)
  */
  return feature;
 });
 if (feature) {
  info.tooltip('hide')
  /** .tooltip('hide')
   * Hides an element's tooltip. Returns to the caller 
   * before the tooltip has actually been hidden (i.e. 
   * before the hidden.bs.tooltip event occurs). 
   * This is considered a "manual" triggering of the 
   * tooltip.
   * 要素のツールチップを非表示にします。ツールチップが実際に
   * 隠される前(すなわち、hidden.bs.tooltipイベントが発生
   * する前)に、caller が返されます。これは、ツールチップの
   * トリガ(trigger:) が manyal とみなされます。
   * (Bootstrap[http://getbootstrap.com/javascript/
   * #tooltips])
   */
   .attr('data-original-title', feature.get('name'))
   /** .attr()
    * Get the value of an attribute for the first element 
    * in the set of matched elements or set one or more 
    * attributes for every matched element.
     * マッチした要素のセットの最初の要素の属性の値を取得するか、
     * すべての一致した要素の1つ以上の属性を設定します。
    * (jQuery[http://api.jquery.com/attr/])
     */
   /** get(key)
    * Gets a value.
    * (ol3 API[説明は Stable Only のチェックを外すと表示])
    */
   .tooltip('fixTitle')
   // 変更した title 属性を tooltip に反映
   .tooltip('show');
   /** .tooltip('show')
    * Reveals an element's tooltip. Returns to the caller 
    * before the tooltip has actually been shown (i.e. 
    * before the shown.bs.tooltip event occurs). 
    * This is considered a "manual" triggering of the 
    * tooltip. Tooltips with zero-length titles are never 
    * displayed.
    * 要素のツールチップをRevealsにします。ツールチップが実際に
    * 表示される前(すなわち、shown.bs.tooltipイベントが発生
    * する前)に、caller が返されます。これは、ツールチップの
    * トリガ(trigger:) が manyal とみなされます。
    * zero-length タイトルのツールチップは決して表示されません。
    * (Bootstrap[http://getbootstrap.com/javascript/
    * #tooltips])
    */
 } else {
  info.tooltip('hide');
 }
};
$(map.getViewport()).on('mousemove', function(evt) {
/** getViewport()
 * Return: Viewport (ol3 API)
 */
// jQuery on イベント
 displayFeatureInfo(map.getEventPixel(evt.originalEvent));
 /** getEventPixel
  * Returns the map pixel position for a browser event.
  * ブラウザイベントに対して、マップのピクセル位置を返します。
  * (ol3 API)
  */
});
map.on('click', function(evt) {
/** on
 * Listen for a certain type of event.
 * あるタイプのイベントをリッスンします。(ol3 API)
 */
 displayFeatureInfo(evt.pixel);
});

originalEvent
「ol.MapBrowserEvent」
(Events emitted as map browser events are instances of this type. See ol.Map for which events trigger a map browser event.
マップブラウザイベントとして発するイベントは、このタイプのインスタンスです。イベントがマップブラウザイベントをトリガする ol.Map を参照してください。)
のメンバ。

ol/ol/mapbrowserevent.js 32行目
 * @param {goog.events.BrowserEvent} browserEvent Browser event.
ol/ol/mapbrowserevent.js 52行目
 this.originalEvent = browserEvent.getBrowserEvent();

goog.events.BrowserEvent
「events.BrowserEvent - Extends goog.events.Event」
(http://docs.closure-library.googlecode.com/git/class_goog_events_BrowserEvent.html)
Accepts a browser event object and creates a patched, cross browser event object. The content of this object will not be initialized if no event object is provided. If this is the case, init() needs to be invoked separately.
events.BrowserEvent。goog.events.Eventを拡張します。
ブラウザイベントオブジェクトを受け入れ、パッチを適用した、クロスブラウザイベントオブジェクトを作成します。イベントオブジェクトが提供されない場合は、このオブジェクトの内容は初期化されません。この場合は、init()は別々に呼び出す必要があります。

「Instance Methods」
getBrowserEvent() ⇒ Event
No description.
Returns: Event  The underlying browser event object. 

2 - ol3ex 31b - KML example 2

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

KML(Keyhole Markup Language) は、Google が開発しました。OGC と Google は、OGC 標準規格に沿うように作業が進められています。
「Open Geospatial Consortium(http://www.opengeospatial.org/)」の「KML(http://www.opengeospatial.org/standards/kml)」に次のようにあります。

*****
1) Overview の一部を抜粋

KML is an XML language focused on geographic visualization, including annotation of maps and images. Geographic visualization includes not only the presentation of graphical data on the globe, but also the control of the user's navigation in the sense of where to go and where to look.
KMLは、地図や画像の注釈を含む地理的可視化に焦点を当てたXML言語です。地理的可視化は、地球上のグラフィカルなデータの提示だけでなく、どこに行きどこを見るというユーザのナビゲーションの制御を含んでいます。

From this perspective, KML is complementary to most of the key existing OGC standards including GML (Geography Markup Language), WFS (Web Feature Service) and WMS (Web Map Service). Currently, KML 2.2 utilizes certain geometry elements derived from GML 2.1.2. These elements include point, line string, linear ring, and polygon.
このような観点から、KML は GML(Geography Markup Language)とWFS(Web Feature Service)、WMS(Web Map Service)を含む主要な既存のOGC 標準規格のほとんどに相補います。現在、KML2.2 が GML2.1.2 に由来し、特定のジオメトリ要素を利用しています。これらの要素は、ポイント、ラインストリング、リニアリング、およびポリゴンが含まれます。
*****

2012-02-10.kml の内容は、次のようになっています。

「2012-02-10.kml」
<kml>
 <Document>
  <name>Skimap.org OpenSkiMap </name>
  <description>Created from OpenStreetMap data. Renderer v0.5</description>
  <!-- 
Copyright (c) OpenStreetMap Contributors
http://www.openstreetmap.org/

This work is licensed under the
Creative Commons Attribution-ShareAlike 2.0 License.
http://creativecommons.org/licenses/by-sa/2.0/
 -->
  <ScreenOverlay id="CopyrightNotice">
   <name>Copyright Notice</name>
   <description>
    <![CDATA[The data in this KML file is Copyright <a href="http://www.openstreetmap.org/">OpenStreetMap</a> Contributors. It is available under the <a href="http://creativecommons.org/licenses/by-sa/2.0/">Creative Commons Attribution-ShareAlike (CC-BY-SA) Version 2.0 License</a>.]]>
   </description>
   <Snippet>Copyright (c) OpenStreetMap Contributors. CC-BY-SA 2.0 License.</Snippet>
   <Icon>
    <href>OSMCopyright.png</href>
   </Icon>
   <overlayXY x="0" xunits="fraction" y="1" yunits="fraction"/>
   <screenXY x="0" xunits="fraction" y="1" yunits="fraction"/>
   <size x="0" xunits="fraction" y="0" yunits="fraction"/>
  </ScreenOverlay>
  <Folder>
   <name>POI</name>
   <description>Points of Interest</description>
  <Folder>
  <name>Parking</name>
  <Style id="style-Parking">
   <IconStyle>
    <scale>0.2</scale>
    <Icon>
     <href>http://maps.google.com/mapfiles/kml/shapes/parking_lot.png</href>
    </Icon>
   </IconStyle>
  </Style>
  <Placemark>
   <styleUrl>#style-Parking</styleUrl>
   <Point>
    <coordinates>7.5584046,46.4880564,0</coordinates>
   </Point>
  </Placemark>
  <Placemark>
   <name>Coop</name>
---

「231-ol3ex.js」
var projection = ol.proj.get('EPSG:3857');
// EPSG:900913 -> EPSG:3857 コード名変更(内容は同じ)
/** ol.proj.get(projectionLike)
 * Fetches a Projection object for the code specified.
 * 指定されたコードのプロジェクション·オブジェクトを取得
 * (ol3 API)
 */
var raster = 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.BingMaps({
 /** ol.source.BingMaps
  * Layer source for Bing Maps tile data.
  * Bing Maps タイルデータのレイヤソース。(ol3 API)
  */
  imagerySet: 'Aerial',
  key: 'Ak-dzM...(省略)'
 })
});
var vector = new ol.layer.Vector({
/** ol.layer.Vector
 * Vector data that is rendered client-side.
 * クライアント側で描画されるベクタデータ。(ol3 API)
 */
 source: new ol.source.KML({
 /** ol.source.KML 
  * Static vector source in KML format
  * KML フォーマットの静的ベクタソース(0l3 API)
  */
  projection: projection,
  // url: 'data/kml/2012-02-10.kml'
  url: 'v3.0.0/examples/data/kml/2012-02-10.kml' // 修正
 })
});
var map = new ol.Map({
 layers: [raster, vector],
 target: document.getElementById('map'),
 view: new ol.View({
  center: [876970.8463461736, 5859807.853963373],
  projection: projection,
  zoom: 10
 })
});
var displayFeatureInfo = function(pixel) {
 var features = [];
 map.forEachFeatureAtPixel(pixel, function(feature, layer) {
 /** forEachFeatureAtPixel
  * Detect features that intersect a pixel on the viewport, 
  * and execute a callback with each intersecting feature. 
  * Layers included in the detection can be configured 
  * through opt_layerFilter. Feature overlays will always 
  * be included in the detection.
  * ビューポート上のピクセルと交差する特徴を検出し、
  * 各交差するフィーチャとコールバックを実行します。
  * 検出に含まれるレイヤが opt_layerFilter を通じて
  * 設定することができます。フィーチャーオーバーレイは
  * 常に検出に含まれます。(ol3 API)
  */
  features.push(feature);
  /** push(elem)
   * Insert the provided element at the end of the 
   * collection.
   * コレクションの最後に供給されたエレメントに挿入します。
   * Name: elem, Type: T, Description: Element
   * (ol3 API)
   */
 });
 if (features.length > 0) {
  var info = [];
  var i, ii;
  for (i = 0, ii = features.length; i < ii; ++i) {
   info.push(features[i].get('name'));
   /** get(key)
    * Gets a value.
    * (ol3 API[説明は Stable Only のチェックを外すと表示])
    */
   /** Array.push
    * 与えられた要素を追加することによって配列を変異させ、
    * (MDN [https://developer.mozilla.org/ja/docs/Web/
    * JavaScript/Reference/Global_Objects/Array/push])
    */
  }
  document.getElementById('info').innerHTML = info.join(', ') || '(unknown)';
  /** Array.join
   * 配列の全ての要素を繋いで文字列にします。
   * (MDN [https://developer.mozilla.org/ja/docs/Web/
   * JavaScript/Reference/Global_Objects/Array/join])
   */
  map.getTarget().style.cursor = 'pointer';
  /** getTarget()
   * Get the target in which this map is rendered. 
   * Note that this returns what is entered as an option or  
   * in setTarget: if that was an element, it returns an 
   * element; if a string, it returns that.
   * レンダリングされたこのマップのターゲットを取得します。
   * これはオプションとして、または setTarget に入力されている
   * ものを返すことに注意してください:それが要素ならば、要素を
   * 返します。文字列ならば、それを返します。(ol3 API)
   */
 } else {
  document.getElementById('info').innerHTML = '&nbsp;';
  map.getTarget().style.cursor = '';
 }
};
$(map.getViewport()).on('mousemove', function(evt) {
/** getViewport()
 * Return: Viewport (ol3 API)
 */
/** jQuery on イベント */
 var pixel = map.getEventPixel(evt.originalEvent);
 /** getEventPixel
  * Returns the map pixel position for a browser event.
  * ブラウザイベントに対して、マップのピクセル位置を返します。
  * (ol3 API)
  */
 displayFeatureInfo(pixel);
});
map.on('click', function(evt) {
/** on
 * Listen for a certain type of event.
 * あるタイプのイベントをリッスンします。(ol3 API)
 */
 displayFeatureInfo(evt.pixel);
});
var exportKMLElement = document.getElementById('export-kml');
if ('download' in exportKMLElement) {
 var vectorSource = /** @type {ol.source.Vector} */ (vector.getSource());
 /** @type 
  * 値のタイプ(型)の説明 - 式などで表示
  * ol.source.Vector の型を使用。
  * (@use JSDoc[http://usejsdoc.org/]より)
  */
 /** getSource()
  * Return: Source(ol3 API)
  */
 exportKMLElement.addEventListener('click', function(e) {
 /** EventTarget.addEventListener
  * addEventListener は、 1 つのイベントターゲットにイベント 
  * リスナーを1 つ登録します。イベントターゲットは、ドキュメント
  * 上の単一のノード、ドキュメント自身、ウィンドウ、あるいは、
  * XMLHttpRequest です。
  * (MDN[https://developer.mozilla.org/ja/docs/Web/API/
  * EventTarget.addEventListener])
  */
  if (!exportKMLElement.href) {
   var features = [];
   vectorSource.forEachFeature(function(feature) {
   /** forEachFeature(callback, opt_this)
    * Iterate through all features on the source, calling 
    * the provided callback with each one. If the callback 
    * returns any "truthy" value, iteration will stop and 
    * the function will return the same value.
    * 提供されたコールバックを呼び出して、ソース上のすべてのフィー
    * チャを反復処理します。コールバックは「truthy」の値を返した
    * 場合、反復が停止し、関数は同じ値を返します。(ol3 API)
    */
    var clone = feature.clone();
    /** clone()
    * Clone this feature. If the original feature has a 
    * geometry it is also cloned. The feature id is not 
     * set in the clone.
     * このフィーチャを複製します。元のフィーチャは、ジオメトリ
     * を有する場合にも複製します。フィーチャ ID は、クローンに
     * 設定されていません。(ol3 API)
     */
    clone.setId(feature.getId()); //clone does not set the id
    /** setId()
     * Set a unique id for this feature. The id may be 
     * used to retrieve a feature from a vector source 
     * with the ol.source.Vector#getFeatureById method.
     * このフィーチャの一意のIDを設定します。 id は 
     * ol.source.Vector の getFeatureById メソッドによる
     * ベクタソースからフィーチャを取り出すために使用する
     * ことができます。(ol3 API)
     */
    /** getId()
     * Return: id(ol3 API)
     */
    clone.getGeometry().transform(projection, 'EPSG:4326');
    /** getGeometry()
     *  Returns the Geometry associated with this feature 
     * using the current geometry name property. By default, 
     * this is geometry but it may be changed by calling 
     * setGeometryName.
     * 現在のジオメトリネームプロパティを使用して、この
     * フィーチャに関連したジオメトリを返します。デフォルト
     * では、ジオメトリですが、setGeometryName を呼び出す
     * ことによって変更することができます。(ol3 API)
     */
    /** transform(source, destination)
     * Transform each coordinate of the geometry from one 
     * coordinate reference system to another. The 
     * geometry is modified in place. For example, a line 
     * will be transformed to a line and a circle to a 
     * circle. If you do not want the geometry modified in 
     * place, first clone() it and then use this function 
     * on the clone.
     * ある座標参照系から別のものへジオメトリの各座標を変換。ジオ
     * メトリは、所定の位置に修正されます。例えば、ラインはライン
     * に、円は円に変換されます。ジオメトリを所定の位置に修正した
     * くない場合、最初にそれを clone() し、それからクローンでこ
     * の関数を使用します。(ol3 API)
     */
    features.push(clone);
   });
   var node = new ol.format.KML().writeFeatures(features);
   /** writeFeatures
    * Encode an array of features in the KML format.
    * KML フォーマットのフィーチャの配列をエンコードします。
    * (ol3 API)
    */
   var string = new XMLSerializer().serializeToString(
   /** XMLSerializer()
    * XMLSerializer can be used to convert DOM subtree or 
    * DOM document into text. XMLSerializer is available to 
    * unprivileged scripts.
    * XmlSerializer は、DOM サブツリーや DOM ドキュメントを
    * テキストに変換するために使用することができます。
    * XmlSerializerを権限のないスクリプトで使用できます。
    * (MDN[https://developer.mozilla.org/en-US/docs/
    * XMLSerializer])
    */
    /** @type {Node} */ (node));
    var base64 = exampleNS.strToBase64(string);
    /** 'example-behavior.js' により文字列を Base64 へ
     * エンコードします。
     */
    exportKMLElement.href =
     'data:application/vnd.google-earth.kml+xml;base64,' + base64;
  }
 }, false);
} else {
 var info = document.getElementById('no-download');
 /**
  * display error message
  */
 info.style.display = '';
}

2 - ol3ex 29b - Tile vector example 2

「tile-vector.js(229-ol3ex.js)」は、マップを表示するための JavaScript ファイルです。
var waterLayer = new ol.layer.Vector({
/** ol.layer.Vector
 * Vector data that is rendered client-side.
 * クライアント側で描画されたベクタデータ。(ol3 API)
 */
 source: new ol.source.TileVector({
 /** ol.source.TileVector
  * A vector source in one of the supported formats, where 
  * the data is divided into tiles in a fixed grid pattern.
  * グリッドパターンに固定されている状態でデータがタイルに分割さ
  * れている、サポートされたフォーマットの一つのベクタソース。
  * (ol3 API)
  */
  format: new ol.format.TopoJSON(),
  /** ol.format.TopoJSON 
   * Feature format for reading and writing data 
   * in the TopoJSON format.
   * TopoJSON フォーマットでデータを読み書きするためのフィー
   * チャのフォーマット。(ol3 API)
   */
  projection: 'EPSG:3857',
  tileGrid: new ol.tilegrid.XYZ({
  /** ol.tilegrid.XYZ
   * Set the grid pattern for sources accessing XYZ 
   * tiled-image servers.
   * XYZタイル画像サーバにアクセスするソースのグリッドパターンを
   * 設定します。(ol3 API)
   */
   maxZoom: 19
  }),
  url: 'http://{a-c}.tile.openstreetmap.us/' +
   'vectiles-water-areas/{z}/{x}/{y}.topojson'
 }),
 style: new ol.style.Style({
 /** ol.style.Style 
  * Base class for vector feature rendering styles.
  * ベクタフィーチャがスタイルを描画するための基本クラス。
  * (ol3 API)
  */
  fill: new ol.style.Fill({
  /** ol.style.Fill 
   * Set fill style for vector features.
   * ベクタフィーチャの塗りつぶしスタイルを設定。(ol3 API)
   */
   color: '#9db9e8'
  })
 })
});
var roadStyleCache = {};
var roadLayer = new ol.layer.Vector({
 source: new ol.source.TileVector({
  format: new ol.format.TopoJSON(),
  projection: 'EPSG:3857',
  tileGrid: new ol.tilegrid.XYZ({
   maxZoom: 19
  }),
  url: 'http://{a-c}.tile.openstreetmap.us/' +
   'vectiles-highroad/{z}/{x}/{y}.topojson'
 }),
 style: function(feature, resolution) {
  var kind = feature.get('kind');
  /** get(key)
   * Gets a value.
   * (ol3 API[説明は Stable Only のチェックを外すと表示])
   */
  var railway = feature.get('railway');
  var sort_key = feature.get('sort_key');
  var styleKey = kind + '/' + railway + '/' + sort_key;
  var styleArray = roadStyleCache[styleKey];
  if (!styleArray) {
   var color, width;
   if (railway) {
    color = '#7de';
    width = 1;
   } else {
    color = {
     'major_road': '#776',
     'minor_road': '#ccb',
     'highway': '#f39'
    }[kind];
    width = kind == 'highway' ? 1.5 : 1;
  /** 条件演算子 condition ? expr1 : expr2 
   * condition: true か false かを評価する条件文です。
   * expr1, expr2: 各々の値の場合に実行する式です。
   * condition が true の場合、演算子は expr1 の値を選択します。
   * そうでない場合は expr2 の値を選択します。
   * (MDN[https://developer.mozilla.org/ja/docs/Web/
   * JavaScript/Guide/Expressions_and_Operators])
   */
   }
   styleArray = [new ol.style.Style({
    stroke: new ol.style.Stroke({
    /** 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)
     */
    color: color,
     width: width
    }),
    zIndex: sort_key
   })];
   roadStyleCache[styleKey] = styleArray;
  }
  return styleArray;
 }
});
var buildingStyle = [
 new ol.style.Style({
  fill: new ol.style.Fill({
   color: '#666',
   opacity: 0.4
  }),
  stroke: new ol.style.Stroke({
   color: '#444',
   width: 1
  })
 })
];
var buildingLayer = new ol.layer.Vector({
 source: new ol.source.TileVector({
  format: new ol.format.TopoJSON({
   defaultProjection: 'EPSG:4326'
  }),
  projection: 'EPSG:3857',
  tileGrid: new ol.tilegrid.XYZ({
   maxZoom: 19
  }),
  url: 'http://{a-c}.tile.openstreetmap.us/' +
   'vectiles-buildings/{z}/{x}/{y}.topojson'
 }),
 visible: false,
 style: function(f, resolution) {
  return (resolution < 10) ? buildingStyle : [];
 }
});
var landuseStyleCache = {};
var landuseLayer = new ol.layer.Vector({
 source: new ol.source.TileVector({
  format: new ol.format.TopoJSON({
   defaultProjection: 'EPSG:4326'
  }),
  projection: 'EPSG:3857',
  tileGrid: new ol.tilegrid.XYZ({
   maxZoom: 19
  }),
  url: 'http://{a-c}.tile.openstreetmap.us/' +
   'vectiles-land-usages/{z}/{x}/{y}.topojson'
 }),
 visible: false,
 style: function(feature, resolution) {
  var kind = feature.get('kind');
  var styleKey = kind;
  var styleArray = landuseStyleCache[styleKey];
  if (!styleArray) {
   var color, width;
   color = {
    'parking': '#ddd',
    'industrial': '#aaa',
    'urban area': '#aaa',
    'park': '#76C759',
    'school': '#DA10E7',
    'garden': '#76C759',
    'pitch': '#D58F8D',
    'scrub': '#3E7D28',
    'residential': '#4C9ED9'
   }[kind];
   width = kind == 'highway' ? 1.5 : 1;
   styleArray = [new ol.style.Style({
    stroke: new ol.style.Stroke({
     color: color,
     width: width
    }),
    fill: new ol.style.Fill({
     color: color,
     opacity: 0.5
    })
   })];
   landuseStyleCache[styleKey] = styleArray;
  }
  return styleArray;
 }
});
var map = new ol.Map({
 layers: [landuseLayer, buildingLayer, waterLayer, roadLayer],
 renderer: 'canvas',
 target: document.getElementById('map'),
 view: new ol.View({
  center: ol.proj.transform([-74.0064, 40.7142], '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)
   */
  maxZoom: 19,
  zoom: 15
 })
});
// チェックボックスの選択状態を取得
$('input[type=checkbox]').on('change', function() {
// jQuery on イベント
 var layer = {
  landuse: landuseLayer,
  buildings: buildingLayer,
  water: waterLayer,
  roads: roadLayer
 }[$(this).attr('id')];
 /** .attr()
  * Get the value of an attribute for the first element in 
  * the set of matched elements or set one or more 
  * attributes for every matched element.
  * マッチした要素のセットの最初の要素の属性の値を取得するか、す
  * べての一致した要素の1つ以上の属性を設定します。
  * (jQuery[http://api.jquery.com/attr/])
  */
 layer.setVisible(!layer.getVisible());
 /** setVisible(visible)
  * Name: visible, Type: boolean, 
  * Description: The visibility of the layer.(ol3 API)
  */
 /** getVisible()
  * Return: The visibility of the layer.(ol3 API)
  */
});


2 - ol3ex 26b - GeoJSON example 2

「geojson.js(226-ol3ex.js)」は、マップを表示するための JavaScript ファイルです。
「The GeoJSON Format Specification(geojson.org/geojson-spec.html)」の「1. Introduction」に次のようにあります。

*****
GeoJSON is a format for encoding a variety of geographic data structures.
GeoJSON は、様々な地理的データ構造を符号化するためのフォーマットです。

A GeoJSON object may represent a geometry, a feature, or a collection of features.
GeoJSONオブジェクトは、ジオメトリ、フィーチャ、またはフィーチャのコレクションを表すことができます。

GeoJSON supports the following geometry types: Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, and GeometryCollection.
GeoJSONは、以下のジオメトリ·タイプをサポートしています:ポイント、ラインストリング、ポリゴン、マルチポイント、マルチストリング、マルチポリゴン、ジオメトリコレクションです。

Features in GeoJSON contain a geometry object and additional properties, and a feature collection represents a list of features.
GeoJSONにおけるフィーチャは、ジオメトリオブジェクトと追加のプロパティが含まれており、フィーチャコレクションはフィーチャのリストを表します。
*****

「226-ol3ex.js」
var image = new ol.style.Circle({
/** ol.style.Circle
 * Set circle style for vector features.
 * ベクタフィーチャの円のスタイルを設定。(ol3 API)
 */
 radius: 5,
 fill: null,
 stroke: new ol.style.Stroke({color: 'red', width: 1})
 /** 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)
  */
});
var styles = {
 'Point': [new ol.style.Style({
 /** ol.style.Style 
  * Base class for vector feature rendering styles.
  * ベクタフィーチャがスタイルを描画するための基本クラス。
  * (ol3 API)
  */
  image: image
 })],
 'LineString': [new ol.style.Style({
  stroke: new ol.style.Stroke({
   color: 'green',
   width: 1
  })
 })],
 'MultiLineString': [new ol.style.Style({
  stroke: new ol.style.Stroke({
   color: 'green',
   width: 1
  })
 })],
 'MultiPoint': [new ol.style.Style({
  image: image
 })],
 'MultiPolygon': [new ol.style.Style({
  stroke: new ol.style.Stroke({
   color: 'yellow',
   width: 1
  }),
  fill: new ol.style.Fill({
  /** ol.style.Fill 
   * Set fill style for vector features.
   * ベクタフィーチャの塗りつぶしスタイルを設定。(ol3 API)
   */
   color: 'rgba(255, 255, 0, 0.1)'
  })
 })],
 'Polygon': [new ol.style.Style({
  stroke: new ol.style.Stroke({
   color: 'blue',
   lineDash: [4],
   width: 3
  }),
  fill: new ol.style.Fill({
   color: 'rgba(0, 0, 255, 0.1)'
  })
 })],
 'GeometryCollection': [new ol.style.Style({
  stroke: new ol.style.Stroke({
   color: 'magenta',
   width: 2
  }),
  fill: new ol.style.Fill({
   color: 'magenta'
  }),
  image: new ol.style.Circle({
   radius: 10,
   fill: null,
   stroke: new ol.style.Stroke({
    color: 'magenta'
   })
  })
 })],
 'Circle': [new ol.style.Style({
  stroke: new ol.style.Stroke({
   color: 'red',
   width: 2
  }),
  fill: new ol.style.Fill({
   color: 'rgba(255,0,0,0.2)'
  })
 })]
};
var styleFunction = function(feature, resolution) {
 return styles[feature.getGeometry().getType()];
 /** getGeometry()
  * Returns the Geometry associated with this feature 
  * using the current geometry name property. 
  * By default, this is geometry but it may be changed 
  * by calling setGeometryName.
  * 現在の geometry name プロパティを使用して、
  * このフィーチャに関連したジオメトリを返します。
  * デフォルトでは、ジオメトリですが、setGeometryName を
  * 呼び出すことによって変更することができます。(ol3 API)
  */
 /** getType()
  * Get the type of this geometry. 
  * ジオメトリの型を取得。(ol3 API)
  */
};
var vectorSource = new ol.source.GeoJSON(
/** ol.source.GeoJSON 
 * Static vector source in GeoJSON format
 * GeoJSON フォーマットの静的ベクタソース。(ol3 API)
 */
 /** @type {olx.source.GeoJSONOptions} */ ({
 /** @type 
  * 値のタイプ(型)の説明 - 式などで表示
  * ol.source.GeoJSON の値の型は、
  * olx.source.GeoJSONOptions の型を使用。
  * (@use JSDoc[http://usejsdoc.org/]より)
  */
 object: {
  'type': 'FeatureCollection',
  'crs': {
   'type': 'name',
   'properties': {
    'name': 'EPSG:3857'
   }
  },
   'features': [
   {
    'type': 'Feature',
    'geometry': {
     'type': 'Point',
     'coordinates': [0, 0]
    }
   },
   {
    'type': 'Feature',
    'geometry': {
     'type': 'LineString',
     'coordinates': [[4e6, -2e6], [8e6, 2e6]]
    }
   },
   {
    'type': 'Feature',
    'geometry': {
     'type': 'LineString',
     'coordinates': [[4e6, 2e6], [8e6, -2e6]]
    }
   },
   {
    'type': 'Feature',
    'geometry': {
     'type': 'Polygon',
     'coordinates': [[[-5e6, -1e6], [-4e6, 1e6], [-3e6, -1e6]]]
    }
   },
   {
    'type': 'Feature',
    'geometry': {
     'type': 'MultiLineString',
     'coordinates': [
      [[-1e6, -7.5e5], [-1e6, 7.5e5]],
      [[1e6, -7.5e5], [1e6, 7.5e5]],
      [[-7.5e5, -1e6], [7.5e5, -1e6]],
      [[-7.5e5, 1e6], [7.5e5, 1e6]]
     ]
    }
   },
   {
    'type': 'Feature',
    'geometry': {
     'type': 'MultiPolygon',
     'coordinates': [
      [[[-5e6, 6e6], [-5e6, 8e6], [-3e6, 8e6], [-3e6, 6e6]]],
      [[[-2e6, 6e6], [-2e6, 8e6], [0, 8e6], [0, 6e6]]],
      [[[1e6, 6e6], [1e6, 8e6], [3e6, 8e6], [3e6, 6e6]]]
     ]
    }
   },
   {
   'type': 'Feature',
    'geometry': {
     'type': 'GeometryCollection',
     'geometries': [
      {
       'type': 'LineString',
       'coordinates': [[-5e6, -5e6], [0, -5e6]]
      },
      {
       'type': 'Point',
       'coordinates': [4e6, -5e6]
      },
      {
       'type': 'Polygon',
       'coordinates': [[[1e6, -6e6], [2e6, -4e6], [3e6, -6e6]]]
      }
     ]
    }
   }
  ]
 }
}));
vectorSource.addFeature(new ol.Feature(new ol.geom.Circle([5e6, 7e6], 1e6)));
/** 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)
 */
/** ol.geom.Circle 
 * Circle geometry. 円のジオメトリ。(ol3 API)
 */
var vectorLayer = new ol.layer.Vector({
/** ol.layer.Vector
 * Vector data that is rendered client-side.
 * クライアント側で描画されたベクタデータ。(ol3 API)
 */
 source: vectorSource,
 style: styleFunction
});
var map = new ol.Map({
 layers: [
  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.OSM()
   /** ol.source.OSM 
    * Layer source for the OpenStreetMap tile server.
    * OpenStreetMap タイルサーバのレイヤソース。(ol3 API)
    */
  }),
  vectorLayer
 ],
 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 
   * 値のタイプ(型)の説明 - 式などで表示
   * attributionOptions の値の型は、
   * olx.control.AttributionOptions の型を使用。
   * (@use JSDoc[http://usejsdoc.org/]より)
   */
   collapsible: false // 折りたたみ
  })
 }),
 view: new ol.View({
  center: [0, 0],
  zoom: 2
 })
});


2014年10月30日木曜日

2 - ol3ex 24b - Stamen example 2

「stamen.js(224-ol3ex.js)」は、マップを表示するための JavaScript ファイルです。
maps.stamen.com(http://maps.stamen.com)次のように、説明があります。

*****
For over a decade, Stamen has been exploring cartography with our clients and in research. These maps are presented here for your enjoyment and use wherever you display OpenStreetMap data.
十年以上にわたって、Stamen は、クライアントと研究に地図作成を模索してきました。これらのマップは、楽しみのためここに提示し、OpenStreetMap のデータを表示する場所ならどこでも使えます。
*****

タイルの種類は、Toner、Terrain、Watercolor、Burning Map、Mars??、Trees, Cabs & Crime があります。
ライセンスについては次のようにあります。

*****
How to Use These Tiles Elsewhere
他の場所でのこれらのタイルの使い方
Except otherwise noted, each of these map tile sets are © Stamen Design, under a Creative Commons Attribution (CC BY 3.0) license.
特に断りのない場合を除き、これらのマップタイルセットはそれぞれ、クリエイティブコモンズ(3.0 BY CC)ライセンスの下で、© Stamen Design(すべての著作権の主張)です。

We’d love to see these maps used around the web, so we’ve included some brief instructions to help you use them in the mapping system of your choice. These maps are available free of charge. If you use the tiles we host here, please use this attribution:
ウェブ中で使用されるこれらのマップを見てみたいの で、選択したマッピングシステムでそれらを使用する際に役立ついくつかの簡単な指示を用意しました。これらのマップは無料で使用できます。ここに提供する タイルを使用している場合は、この attribution を使用してください:

Attribution:

For Toner(Toner 用): Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under ODbL.

For everything else(その他用): Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under CC BY SA.

If you roll your own tiles from another source you will still need to credit “Map data by OpenStreetMap, under ODbL.” And if you do use these maps elsewhere, please post a tweet to @stamen!
別のソースから独自のタイルをアレンジした場合でも、「Map data by OpenStreetMap, under ODbL.」のクレジットが必要になります。そして、他の場所でこれらのマップを使用する場合は、@stamen にツイートしてください!

Isn't OSM data provided under the ODbL now? Yes, but the data used in our some of our map tiles pre-dates the license change, so it remains CC BY SA until it's refreshed.
OSM のデータは、今、ODbL の下で提供されてませんか?はい、しかしマップタイルの一部で使用されるデータは、ライセンスの変更にさかのぼるので、それがリフレッシュされるまで、SA BY CC のままです。
*****

「224-ol3ex.js」
var map = new ol.Map({
 layers: [
  new ol.layer.Tile({
  /** 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)
   */
   source: new ol.source.Stamen({
   /** ol.source.Stamen
    * Layer source for the Stamen tile server.
    * Stamen タイルサーバのレイヤソース。(ol3 API)
    */
    layer: 'watercolor'
   })
  }),
  new ol.layer.Tile({
   source: new ol.source.Stamen({
    layer: 'terrain-labels'
   })
  })
 ],
 renderer: exampleNS.getRendererFromQueryString(),
 // 'example-behavior.js' により URL にある renderer を返します
 target: 'map',
 view: new ol.View({
  center: ol.proj.transform(
  /** 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)
   */
   // [-122.416667, 37.783333], 'EPSG:4326', 'EPSG:3857'),
   [139.72, 35.68], 'EPSG:4326', 'EPSG:3857'),//東京周辺に修正
  zoom: 12
 })
});

2 - ol3ex 23b - MapQuest example 2

「mapquest.js(223-ol3ex.js)」は、マップを表示するための JavaScript ファイルです。
「MapQuest(http://wiki.openstreetmap.org/wiki/MapQuest)」に、次のようにあります。
MapQuest is an online mapping company based in the United States and is wholly-owned by AOL.
MapQuest は、米国に拠点を置くオンライン地図会社であり、AOLに完全所有されています。
MapQuest is one of the pioneers in online mapping and holds a significant market share in the U.S.
MapQuest は、オンラインマッピングの先駆者の一つであり、米国で大きな市場シェアを保持しています。
During the State Of The Map 2010, the company announced their support for OpenStreetMap making MapQuest the first large online mapping service to embrace OSM.
State Of The Map 2010 の期間に、同社は MapQuest を、OpenStreetMap を採用した最初の大規模なオンラインマッピングサービスにするために、OSM に対するサポートを発表しました。

また、「mapquest company(http://company.mapquest.com/)」には、次のようにあります。
Welcome to MapQuest.
MapQuest, Inc. offers online, mobile, business and developer solutions that help people discover and explore where they would like to go, how to get there and what to do along the way and at your destination.
MapQuest 社は、道中や目的地について、行きたい場所、そこに着く方法、行うことを発見し、探る手助けをするオンライン、モバイル、ビジネスおよび開発ソリューションを提供しています。

Building on the core premise of providing accurate maps and directions to millions of people everyday, MapQuest.com is committed to making it easy for you to find local information, create your trips or journeys and customize, personalize and share them with others.
毎日、何百万人もの人に正確な地 図と方向を提供することを前提にしたコアを再構築するために、MapQuest.comは、簡単にローカル情報を検索し、日帰りや長期の旅行を作成し、そ してそれらを、カスタマイズし、パーソナライズし、他の人と共有できるように取り組んでいます。

ライセンスについて は、「mapquest developer」の「Licensed Data vs. Open Data(http://developer.mapquest.com/web/tools/getting-started/platform /licensed-vs-open)」を参照してください。

「223-ol3ex.js」
var layers = [
 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)
  */
  style: 'Road',
  source: new ol.source.MapQuest({layer: 'osm'})
  /** ol.source.MapQuest
   * Layer source for the MapQuest tile server.
   * MapQuest タイルサーバのレイヤソース。(ol3 API
   * 2 - ol3ex 23b - MapQuest example 2 参照)
   */
  // Source for this layer.(このレイヤのソース。ol3 API)
 }),
 new ol.layer.Tile({
  style: 'Aerial',
  visible: false,
  // Visibility. Default is true (表示。ol3 API)
  source: new ol.source.MapQuest({layer: 'sat'})
 }),
 new ol.layer.Group({
 /** ol.layer.Group
  * A ol.Collection of layers that are handled together.
  * 同時に扱うレイヤの ol.Collection(ol3 API)
  */
 /** ol.Collection
  * An expanded version of standard JS Array, adding 
  * convenience methods for manipulation. Add and remove 
  * changes to the Collection trigger a Collection event. 
  * Note that this does not cover changes to the objects 
  * within the Collection; they trigger events on the 
  * appropriate object, not on the Collection as a whole.
  * 操作のための便利なメソッドを追加する、標準JSアレイの拡張バー
  * ジョン。コレクションイベントをトリガするコレクションの変更の
  * 追加と削除をします。これはコレクション内のオブジェクトへの変
  * 更に及ばないことに注意してください。コレクション全体としてで
  * はなく、適切なオブジェクトにイベントをトリガします。
  * Because a Collection is itself an ol.Object, it can 
  * be bound to any other Object or Collection such 
  * that a change in one will automatically be reflected 
  * in the other.
  * コレクションは、ol.Object そのものであるため、ある変化が自
  * 動的に他方に反映されるように、他のオブジェクトまたはコレク
  * ションに結合させることができます。
  * (ol3 API)
  */
  style: 'AerialWithLabels',
  visible: false,
  layers: [
   new ol.layer.Tile({
    source: new ol.source.MapQuest({layer: 'sat'})
   }),
   new ol.layer.Tile({
    source: new ol.source.MapQuest({layer: 'hyb'})
   })
  ]
 })
];
var map = new ol.Map({
 layers: layers,
 renderer: exampleNS.getRendererFromQueryString(),
 //'example-behavior.js' により URL にある renderer を返します
 target: 'map',
 view: new ol.View({
  center: ol.proj.transform(
  /** 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)
   */
// [-73.979378, 40.702222], 'EPSG:4326', 'EPSG:3857'),
   [139.42, 35.68], 'EPSG:4326', 'EPSG:3857'),//東京周辺に修正
  zoom: 9
 })
});
// リストから選んだスタイルに変更するコード
$('#layer-select').change(function() {
// 223-ol3ex.html の select タグの id
/** .change(handler)
 * Bind an event handler to the "change" JavaScript event, or 
 * trigger that event on an element.
 * 「change」JavaScript イベントにイベントハンドラをバインド、ま
 * たは、要素についてそのイベントをトリガします。
 * (jQuery[https://api.jquery.com/change/])
 */
 var style = $(this).find(':selected').val();
 // 223-ol3ex.html の select タグで挟まれた option タグの要素
 (初期表示)
 /** .find(selector)
  * Get the descendants of each element in the current set of 
  * matched elements, filtered by a selector, jQuery object, 
  * or element.
  * セレクタによるフィルタリングで、マッチした要素、または、
  * jQueryオブジェクト、要素の現在のセット中の各要素の子孫要素
  * を取得します。(jQuery[https://api.jquery.com/find/])
  */
 /** .val()
  * Get the current value of the first element in the set of 
  * matched elements or set the value of every matched 
  * element.
  * マッチした要素のセットの最初の要素の現在の値を取得、または、
  * すべての一致した要素の値を設定します。
  * (jQuery[https://api.jquery.com/val/])
  */
 var i, ii;
 for (i = 0, ii = layers.length; i < ii; ++i) {
  layers[i].set('visible', (layers[i].get('style') == style));
  //layers(配列)から合った ol.layer.* のオプション(visible, 
  //style)に変更
  /** set(key, value) 
   * Sets a value.
   * (ol3 API[説明は Stable Only のチェックを外すと表示])
   */
  /** get(key)
   * Gets a value.
   * (ol3 API[説明は Stable Only のチェックを外すと表示])
   */
 }
});
$('#layer-select').trigger('change');
/**.trigger(eventType [,extraParameters]
 * Execute all handlers and behaviors attached to the 
 * matched elements for the given event type.
 * 指定されたイベントタイプにマッチした要素に接続されているすべ
 * てのハンドラや動作を実行します。
 * (jQuery[https://api.jquery.com/trigger/])
 */

2 - ol3ex 22b - Localized OpenStreetMap example 2

OpenCycleMap と OpenSeaMap は、OpenStreetMap を元に作成された地図です。
日本で、OpenCycleMap は作成されていますが、 OpenSeaMap はありません。(OpenSeaMap は、ドイツ北部の海域をサポートしています。)

OpenCycleMap(http://www.opencyclemap.org/)
OpenCycleMap(http://www.opencyclemap.org/docs/)に次のようにあります。

The OpenCycleMap global cycling map is based on data from the OpenStreetMap project. At low zoom levels it is intended for overviews of national cycling networks; at higher zoom levels it should help with planning which streets to cycle on, where you can park your bike and so on.
OpenCycleMap グローバルサイクリングマップは、OpenStreetMap のプロジェクトのデータに基づいています。低いズームレベルでは、全国のサイクリングネットワークの概要を対象としています。高いズームレベルでは、バイクを駐車できる場所のように、サイクルリング(ツーリング)の行程の計画に役立てることができます。
The map is updated every few days with the latest data from OpenStreetMap. News about OpenCycleMap can be found in the OpenStreetMap archives on my blog.
マップは、OpenStreetMap の最新データで数日ごとに更新されます。 OpenCycleMap についてのニュースは、私のブログで OpenStreetMap のアーカイブで見つけることができます。

OpenSeaMap(http://www.openseamap.org/)
OpenSeaMap Wiki(http://wiki.openstreetmap.org/wiki/OpenSeaMap)に次のようにあります。

History and fundamentals
OpenSeaMap was created in 2009 in response to a great need for freely-accessible seafaring maps. OpenSeaMap's goal is to add nautical and tourism information that would interest sailors OSM, and to present it in a pleasing way. This includes beacons, buoys and other seamarks, port information, repair shops, ship supplies and much more, but also shops, restaurants and places of interest. OpenSeaMap is part of OpenStreetMap and uses its database.
OpenSeaMap は、自由にアクセス可能な船乗り用マップに対する大きな要求に応じて、2009年に作成されました。 OpenSeaMap の目標は、航路や船員のOSMの興味になる観光の情報を追加することと、楽しい方法でそれを提示するです。これはショップ、レストラン、興味のある場所だけでなく、ビーコン、ブイ、他の航路目標、ポート情報、修理工場、船舶用品やさらに多くのものが含まれています。 OpenSeaMap は OpenStreetMap の一部であり、そのデータベースを使用しています。

「222-ol3ex.js」
/** tiles.openseamap.org does not set CORS headers, so we 
 * have to disable crossOrigin and we cannot use WebGL.
 * tiles.openseamap.org は CORS ヘッダを設定していないので、
 * crossOrigin を無効にする必要があり、WebGL を使用するこ
 * とはできません。
 */
var openCycleMapLayer = 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.OSM({
 /** ol.source.OSM 
  * Layer source for the OpenStreetMap tile server.
  * OpenStreetMap タイルサーバのレイヤソース。(ol3 API)
  */
  attributions: [
   new ol.Attribution({
   /** ol.Attribution
    * An attribution for a layer source.
    * レイヤソースの属性(ol3 API)
    */
    html: 'All maps &copy; ' +
     '<a href="http://www.opencyclemap.org/">OpenCycleMap</a>'
   }),
   ol.source.OSM.DATA_ATTRIBUTION
   // v3.1.0 以降 ol.source.OSM.ATTRIBUTION を使用
  ],
  url: 'http://{a-c}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png'
 })
});
var openSeaMapLayer = new ol.layer.Tile({
 source: new ol.source.OSM({
  attributions: [
   new ol.Attribution({
    html: 'All maps &copy; ' +
     '<a href="http://www.openseamap.org/">OpenSeaMap</a>'
    }),
    ol.source.OSM.DATA_ATTRIBUTION
   // v3.1.0 以降 ol.source.OSM.ATTRIBUTION を使用
  ],
  crossOrigin: null,
  /** crossOrigin
   * The crossOrigin attribute for loaded images. Note 
   * that you must provide a crossOrigin value if you 
   * are using the WebGL renderer or if you want to 
   * access pixel data with the Canvas renderer. See 
   * https://developer.mozilla.org/en-US/docs/Web/HTML/
   * CORS_enabled_image for more detail.
   * ロードされたイメージの crossOrigin属性。WebGLのレンダ
   * ラーを使用している場合、または、キャンバスレンダラでピ
   * クセルデータにアクセスする場合、crossOrigin 値を提供な
   * ければならないことに注意してください。詳細は 
   * https://developer.mozilla.org/en-US/docs/Web/HTML/
   * CORS_enabled_image を参照してください。(ol3 API)
   */
  url: 'http://tiles.openseamap.org/seamark/{z}/{x}/{y}.png'
 })
});
var map = new ol.Map({
 layers: [
  openCycleMapLayer,
  openSeaMapLayer
 ],
 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()
  * デフォルトでは、マップに含まコントロールのセット。
  * 特に設定しない限り、これは、以下の各コントロールの
  * インスタンスを含むコレクションを返します。(API Doc より)
  * ol.control.Zoom, ol.control.Rotate, ol.control.Attribution
  */
  attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
  /** @type 
   * 値のタイプ(型)の説明 - 式などで表示
   * attributionOptions の値の型は、
   * olx.control.AttributionOptions の型を使用。
   * (@use JSDoc[http://usejsdoc.org/]より)
   */
   collapsible: false // 折りたたみ
  })
 }),
 view: new ol.View({
  maxZoom: 18,
  center: [-244780.24508882355, 5986452.183179816],
  zoom: 15
 })
});
 

2014年10月22日水曜日

2 - ol3ex 21b - WFS example 2

OpenLayers 2 では、ドメインの違うサーバから WFS でデータを取得するのに、proxy.cgi ファイルを設定しました。OpenLayers 3 は、別の手順で取得します。
vector-wfs.js で、自分の GeoServer から WFS のデータを次のようにリクエストします。
var url = 'http://localhost:8080/geoserver/wfs?service=WFS&' +
 'version=1.1.0&request=GetFeature&typename=npn:akiruno_suiiki&' +
 'outputFormat=text/javascript&format_options=callback:loadFeatures' +
 '&srsname=EPSG:2451&bbox=' + extent.join(',') + ',EPSG:2451';

Geoserver に WFS をリクエストするとき、オプションを 「outputFormat=text/javascript」とすると、JSON形式で取得できます。

vector レイヤは表示されませんでした。
Firebug を起動して再表示すると、次のように表示されました。

データが、XML(GML)で送信されています。
Google で検索すると、「Geographic Information Systems Stack Exchange」の「GeoServer 2.3 how to enable jsonp(http://gis.stackexchange.com/questions/57494/geoserver-2-3-how-to-enable-jsonp)」に、

---
Add to this file: /tomcat/webapps/geoserver/WEB-INF/web.xml
<context-param>
 <param-name>ENABLE_JSONP</param-name>
 <param-value>true</param-value>
</context-param>
---

とあります。自分のサーバでは、

user@debian7-vmw:~$ su
パスワード:
root@debian7-vmw:/home/user# vim /etc/tomcat7/web.xml
---
 <context-param>
  <param-name>ENABLE_JSONP</param-name>
  <param-value>true</param-value>
 </context-param>

</web-app>
:wq

と、ファイルに追加し、tomcat7 を再起動します。

root@debian7-vmw:/home/user# /etc/init.d/tomcat7 restart
[ ok ] Stopping Tomcat servlet engine: tomcat7.
[ ok ] Starting Tomcat servlet engine: tomcat7.

Firebug に何も表示されませんが、地図にも表示されません。
Webブラウザのアドレスバーに次のように入力します。

http://localhost:8080/geoserver/wfs?service=WFS&version=1.1.0&request=GetFeature&typename=npn:akiruno_suiiki&outputFormat=text/javascript&format_options=callback:loadFeatures&srsname=EPSG:2451
loadFeatures({
 "type":"FeatureCollection",
 "features":[{
  "type":"Feature",
  "id":"akiruno_suiiki.1",
  "geometry":{
   "type":"MultiPolygon",
   "coordinates":[[[[-45875.83465282351,-29805.840956966127],
---
   [-45875.83465282351,-29805.840956966127]]]]},
  "geometry_name":"the_geom",
  "properties":{
   "id":"K12_1",
   "uuid":"fgoid:10-00200-11-6554-5598",
   "presences":2.0120305E7,
   "presencef":2.9991231E7,
   "finished":2.0120305E7,
   "orggilvl":"2500",
   "orgmdid":null,
   "category":"表示",
   "flag":"既存",
   "type":"湖池",
   "name":null}},
---

このままでは変換が必要ですが、「srsname=EPSG:3857」にすると座標が EPSG:3857 になります。

http://localhost:8080/geoserver/wfs?service=WFS&version=1.1.0&request=GetFeature&typename=npn:akiruno_suiiki&outputFormat=text/javascript&format_options=callback:loadFeatures&srsname=EPSG:3857
loadFeatures({
 "type":"FeatureCollection",
 "features":[{"type":"Feature",
 "id":"akiruno_suiiki.1",
 "geometry":{
  "type":"MultiPolygon",
  "coordinates":[[[[1.5509721608105533E7,4263571.24847886],
---
  [1.5509721608105533E7,4263571.24847886]]]]},
 "geometry_name":"the_geom",
 "properties":{
  "id":"K12_1",
  "uuid":"fgoid:10-00200-11-6554-5598",
  "presences":2.0120305E7,
  "presencef":2.9991231E7,
  "finished":2.0120305E7,
  "orggilvl":"2500",
  "orgmdid":null,
  "category":"表示",
  "flag":"既存",
  "type":"湖池",
  "name":null}},
---

「url」を次のようにすると地図が表示されました。
var url = 'http://localhost:8080/geoserver/wfs?service=WFS&' +
 'version=1.1.0&request=GetFeature&typename=npn:akiruno_suiiki&' +
 'outputFormat=text/javascript&format_options=callback:loadFeatures' +
 '&srsname=EPSG:3857&bbox=' + extent.join(',') + ',EPSG:3857';

「vector-wfs.js(221-ol3ex.js)」は、地図を表示するのに必要な javascript です。
「221-ol3ex.js」
var vectorSource = new ol.source.ServerVector({
/** ol.source.ServerVector
 * A vector source in one of the supported formats, using
 * a custom function to read in the data from a remote 
 * server.
 * サポートされている形式の一つのベクトルソースは、
 * カスタム関数を使用してリモートサーバからデータを読み取ります。
 * (ol3 APL)
 */
 format: new ol.format.GeoJSON(),
 /** ol.format.GeoJSON 
  * Feature format for reading and writing data 
  * in the GeoJSON format.
  * GeoJSON フォーマットのデータを読み書きするための
  * フィーチャフォーマット。(ol3 API)
  */
 loader: function(extent, resolution, projection) {
  /**var url = 'http://demo.opengeo.org/geoserver/wfs?service=WFS&' +
   *  'version=1.1.0&request=GetFeature&typename=osm:water_areas&' +
   *  'outputFormat=text/javascript&format_options=callback:loadFeatures' +
   *  '&srsname=EPSG:3857&bbox=' + extent.join(',') + ',EPSG:3857';
   */
  var url = 'http://localhost:8080/geoserver/wfs?service=WFS&' +
   'version=1.1.0&request=GetFeature&typename=npn:akiruno_suiiki&' +
   'outputFormat=text/javascript&format_options=callback:loadFeatures' +
   '&srsname=EPSG:3857&bbox=' + extent.join(',') + ',EPSG:3857';
   // outputFormat=text/javascript: JSONP 形式で返信
  $.ajax({
  /** $.ajax( [url] [, settings] )
   * 非同期HTTP通信(Ajax)を行い、データの取得・処理を行います。
   * [url] String リクエスト送信先のURL
   * [settings] Object Ajaxリクエストでのオプションを記述したオ
   * ブジェクト(jQuery)
   */
   url: url,
   dataType: 'jsonp'
   /** JSONP (JSON with Padding)
    * さまざまなドメインから、JSON データを持った JavaScript を
    * 動的に挿入することができます。
    */
  });
 },
 strategy: ol.loadingstrategy.createTile(new ol.tilegrid.XYZ({
 /** ol.loadingstrategy
  * Strategies for loading vector data.
  * ベクタデータをローディングするための方法。
  * createTile 
  * ol.loadingstrategy のメソッド
  * (ol3 API)
  */
 /** ol.tilegrid.XYZ
  * Set the grid pattern for sources accessing XYZ 
  * tiled-image servers.
  * XYZタイル画像サーバにアクセスするソースのグリッドパターンを
  * 設定します。
  * (ol3 API)
  */
  maxZoom: 19
 })),
 projection: 'EPSG:3857',
 attributions: [new ol.Attribution({
 /** ol.Attribution
  * An attribution for a layer source.
  * レイヤソースの属性(ol3 API)
  */
  html: '<a href="http://portal.cyberjapan.jp/help/termsofuse.html" target="_blank">' + 
   '国土地理院</a> 基盤地図情報'
 })],
});
var loadFeatures = function(response) {
 vectorSource.addFeatures(vectorSource.readFeatures(response));
 /** addFeatures
  * ol.source.GeoJSON (Static vector source in GeoJSON 
  * format[GeoJSONフォーマットの静的ベクトルソース])のメソッド
  */
 /** readFeatures
  * ol.format.GeoJSON  (Feature format for reading and 
  * writing data in the GeoJSON format. [GeoJSONフォーマットで
  * データを読み書きするための機能の形式。])のメソッド
  * Read all features from a GeoJSON source. 
  * GeoJSONソースからすべてのフィーチャをお読み込む。
  * Works with both Feature and FeatureCollection sources.
  * フィーチャおよびフィーチャコレクションソースの両方で動作。
  * (ol3 API)
  */
};
var vector = new ol.layer.Vector({
/** ol.layer.Vector 
 * Vector data that is rendered client-side. Note that any 
 * property set in the options is set as a ol.Object property
 * on the layer object; for example, setting title: 'My 
 * Title' in the options means that title is observable, and 
 * has get/set accessors.
 * クライアント側で描画されたベクタデータ。オプションで設定した任
 * 意のプロパティは、レイヤオブジェクトで ol.Object プロパティ
 * として設定されていることに注意してください。たとえば、オプショ
 * ンで、title:'My Title' を設定することは、タイトルは 
 * observable で、アクセサを取得/設定することを意味します。
 * (ol3 API)
 */
 source: vectorSource,
 style: new ol.style.Style({
 /** ol.style.Style 
  * Base class for vector feature rendering styles.
  * ベクタフィーチャがスタイルを描画するための基本クラス。
  * (ol3 API)
  */
  stroke: new ol.style.Stroke({
  /** 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)
   */
   color: 'rgba(0, 0, 255, 1.0)',
   width: 2
  })
 })
});
var raster = 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.BingMaps({
 /** ol.source.BingMaps
  * Layer source for Bing Maps tile data.
  * Bing Maps タイルデータのレイヤソース。(ol3 API)
  */
  imagerySet: 'Aerial',
  key: 'Ak-dzM4***' // 省略してます
 })
});
var map = new ol.Map({
 layers: [raster, vector],
 target: document.getElementById('map'),
 view: new ol.View({
  //center: [-8908887.277395891, 5381918.072437216]
  center: [15499413.571008531, 4264076.282950245],
  maxZoom: 19,
  zoom: 12
 })
});

2 - ol3ex 20b - WMTS example 2

WMTS データは、「独立行政法人 産業技術総合研究所(http://www.aist.go.jp/)」の「GSJ 地質調査総合センター(https://www.gsj.jp/HomePageJP.html)」の「地質情報配信サービス(https://gbank.gsj.jp/owscontents/)」の「20万分の1日本シームレス地質図 基本版(https://gbank.gsj.jp/seamless/tilemap/basic/WMTSCapabilities.xml)」を使用します。

「Webサイトでのご利用」に「OpenLayersでの利用例」があります。「OpenLayersでのWMTSサービス利用例 (実装例ソースコード)」は OpenLayers 2.x の例ですが、これを参考に ol3 に応用します。

「OpenLayersでのWMTSサービス利用例(https://gbank.gsj.jp/owscontents/ol_example.html#WMTS)」
実装例ソースコード(https://gbank.gsj.jp/owscontents/ol_example_wmts_html.txt)

「wmts.js(220-ol3ex.js)」は、地図を表示するのに必要な javascript です。
「220-ol3ex.js」
var projection = ol.proj.get('EPSG:3857');
// EPSG:900913 -> EPSG:3857 コード名変更(内容は同じ)
/** ol.proj.get(projectionLike)
 * Fetches a Projection object for the code specified.
 * 指定されたコードのプロジェクション·オブジェクトを取得
 * (ol3 API)
 */
var projectionExtent = projection.getExtent();
/** getExtent()
 * Get the validity extent for this projection.
 * この投影の有効範囲を取得。(ol3 API)
 */
var size = ol.extent.getWidth(projectionExtent) / 256;
/** ol.extent.getWidth(extent)
 * Return: Width.(ol3 API)
 */
var resolutions = new Array(14);
/** Array(arraylength)
 * JavaScript は配列を扱うことができます。配列とは順序を持つ複数
 * のデータの集合であり、JavaScript のグローバルオブジェクトであ 
 * る Array は、高位の、(C言語等で云うところの)「リスト」の様
 * な、配列のコンストラクタです。
 * arraylength
 * Array コンストラクタに渡される唯一の引数(arrayLength)に 0 
 * から 4,294,967,295( 232-1 ) までの整数値を指定する場合は、そ
 * の値を要素数とする配列が作成されます。その際に範囲外の値を指
 * 定した場合には、例外: RangeError がスローされます。
 * (MDN[https://developer.mozilla.org/ja/docs/Web/
 * JavaScript/Reference/Global_Objects/Array])
 */
var matrixIds = new Array(14);
for (var z = 0; z < 14; ++z) {
 // generate resolutions and matrixIds arrays for this WMTS
 // この WMTS の解像度と matrixIds 配列の生成。(ol3 API)
 resolutions[z] = size / Math.pow(2, z);
 /** Math.pow(base, exponent)
  * base を exponent 乗した値、つまり、base^exponent の値を返
  * します。
  * (MDN[https://developer.mozilla.org/ja/docs/Web/
  * JavaScript/Reference/Global_Objects/Math/pow])
  */
 matrixIds[z] = z;
}
var attribution = new ol.Attribution({
/** ol.Attribution
 * An attribution for a layer source.
 * レイヤソースの属性(ol3 API)
 */
/**
 * html: 'Tiles &copy; <a href="http://services.arcgisonline.com/arcgis/rest/' +
 * 'services/Demographics/USA_Population_Density/MapServer/">ArcGIS</a>'
 */
 html: 'Tiles &copy; 産総研地質調査総合センター 20万分の1日本シームレス地質図 (基本版) CC BY-ND'
});
var map = new ol.Map({
 layers: [
  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.OSM(),
   /** ol.source.OSM 
    * Layer source for the OpenStreetMap tile server.
    * OpenStreetMap タイルサーバのレイヤソース。(ol3 API)
    */
   opacity: 0.7 // 透過度
  }),
  new ol.layer.Tile({
   opacity: 0.7,
   extent: projectionExtent, // 範囲
   source: new ol.source.WMTS({
   /** ol.source.WMTS
    * Layer source for tile data from WMTS servers.
    * WMTSサーバからタイルデータのレイヤソース。(ol3 API)
    */
    attributions: [attribution],
    /**
     * url: 'http://services.arcgisonline.com/arcgis/rest/' +
     * 'services/Demographics/USA_Population_Density/MapServer/WMTS/',
     */
    url: 'https://gbank.gsj.jp/seamless/tilemap/basic/glfn/{TileMatrix}/{TileRow}/{TileCol}.png',
    /** WMTSサービスのベースURLを設定します。
      * 標準形式のURLでない場合、URLのテンプレートを設定します。(地質調査総合センター)
      */
    // layer: '0', // The layer identifier.
    layer: 'glfn',
     /** ベースURLから取得するレイヤ名を設定します。
      * このサンプルでは、レイヤ名を固定的に持つURLテンプレートを
      * 設定しているため使用されることはありませんが、WMTS クラス
      * コンストラクタの必須パラメータなので省略できません。
      * (地質調査総合センター)
      */
    matrixSet: 'EPSG:3857',
    // EPSG:900913 -> EPSG:3857 コード名変更(内容は同じ)
    format: 'image/png',
    projection: projection,
    tileGrid: new ol.tilegrid.WMTS({
    /** ol.tilegrid.WMTS
     * Set the grid pattern for sources accessing WMTS tiled-image servers.
     * WMTSタイル画像サーバにアクセスするソースのグリッドパターンを設定(ol3 API)
     */
     origin: ol.extent.getTopLeft(projectionExtent),
     /** ol.extent.getTopLeft
      * Return: Top left coordinate.
      */
     resolutions: resolutions,
     matrixIds: matrixIds
     /** matrixIds
      * matrix IDs. The length of this array needs to match 
      * the length of 
      * the resolutions array.
      * 行列のID。この配列の長さは、解像度配列の数と一致する必要
      * があります。
      * (ol3 API[説明は Stable Only のチェックを外すと表示])
      */
    }),
    style: 'default',
    requestEncoding: "REST"
     /** リクエスト形式が REST か KVP を設定します。
      * 省略するとデフォルトの KVP が適用されます。
      * (地質調査総合センター)
      */
   })
  })
 ],
 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/]より)
   * attributionOptions の値の型は、
   * olx.control.AttributionOptions の型を使用。
    */
   collapsible: false // 折りたたみ
  })
 }),
& view: new ol.View({
  // center: [-11158582, 4813697],
  center: [15500000,4210000],
  // デフォルトの中心座標を指定しています。(地質調査総合センター)
  //  zoom: 4
  zoom: 6
 })
});

2 - ol3ex 19b - EPSG:4326 example 2

「epsg-4326.js(219-ol3ex.js)」は、地図を表示するのに必要な javascript です。「219-ol3ex.js」
var layers = [
 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.TileWMS({
  /** ol.source.TileWMS
   * Layer source for tile data from WMS servers.
   * WMS サーバからのタイルデータのレイヤソース。
   * (ol3 API)
   */
/**
 * url: 'http://demo.opengeo.org/geoserver/wms',
 * params: {
 *  'LAYERS': 'ne:NE1_HR_LC_SR_W_DR'
 */
   url: 'http://localhost:8080/geoserver/wms?',
   attributions: [new ol.Attribution({
    html: '国土交通省 国土数値情報'
   })],
   params: {'LAYERS': 'npn:tokyo_kuiki', 'TILED': true},
   serverType: 'geoserver'
  })
 })
];
var map = new ol.Map({
 controls: ol.control.defaults().extend([
 /** 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
  */
  new ol.control.ScaleLine({
  /** ol.control.ScaleLine
   * A control displaying rough x-axis distances, calculated 
   * for the center of the viewport. No scale line will be 
   * shown when the x-axis distance cannot be calculated in 
   * the view projection (e.g. at or beyond the poles in 
   * EPSG:4326). By default the scale line will show in the 
   * bottom left portion of the map, but this can be changed 
   * by using the css selector .ol-scale-line.
   * 粗いx軸の距離を表示するコントロール、ビューポートの中心に
   * 対して計算します。 x軸距離がビュー投影(例えば、
   * EPSG:4326 の極で、または、超えて)で計算することができ
   * ないときにスケールラインは表示されません。デフォルトでは、
   * スケールラインがマップの左下部分に表示されますが、これは 
   * CSSセレクタ .ol-scale-line を使用して変更することが
   * できます。(ol3 API)
   */
   units: 'degrees'
  })
 ]),
 layers: layers,
 target: 'map',
 view: new ol.View({
  projection: 'EPSG:4326',
//center: [0, 0],
  center: [139.42, 35.68],
//zoom: 2
  zoom: 10
 })
});