2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CesiumAdvent Calendar 2017

Day 7

cesiumでmapserverを使う。

Last updated at Posted at 2017-12-10

#概要
cesiumでmapserverを使ってみた。
mapserverは、山形県しかない。
タイルの指定が違うので、UrlTemplateImageryProviderでcustomTagsを使った。

#写真

image.png

#サンプルコード

function fromPointToLatLng(x, y, z) {
    var max_zoom = Math.pow(2, z);
	var size = (1 << max_zoom) * 256;
    var lx = (x * 256 + 128) / max_zoom;
    var ly = (y * 256 + 128) / max_zoom;
	var	lat = (2 * Math.atan(Math.exp((ly - size / 2) / -(size / (2 * Math.PI)))) - (Math.PI / 2)) * (180 / Math.PI);
	var	lng = (lx - size / 2) * (360 / size);
    return {lat, lng};
}
var widget = new Cesium.CesiumWidget('cesiumContainer', {
    imageryProvider: new Cesium.UrlTemplateImageryProvider({
        url: "http://yumeblog.dip.jp/yb2g0.php?zoom={z}&long={lon}&lat={lat}",
        customTags: {
            lat: function(imageryProvider, x, y, level) {
                var ll = fromPointToLatLng(x, y, level);
                return ll.lat;
            },
            lon: function(imageryProvider, x, y, level) {
                var ll = fromPointToLatLng(x, y, level);
                return ll.lng;
            }
        }
    })
});
widget.camera.flyTo({
    destination: Cesium.Cartesian3.fromDegrees(140.0 + 0.4, 38.0 - 0.1, 20000.0),
    orientation: {
        heading: Cesium.Math.toRadians(-10.0),
        pitch: Cesium.Math.toRadians(-15.0),
        roll: 0.0
    }
});

#成果物
http://jsdo.it/ohisama1/qIAa

以上。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?