LoginSignup
0
0

More than 5 years have passed since last update.

Mapserver その2

Last updated at Posted at 2017-03-14

概要

Mapserverの地図をleafletで表示してみた。

写真

成果物

サンプルコード

var map = L.map('map').setView([38.0, 140.0], 11);
var mvr = L.tileLayer("", {
    attribution: 'mvr',
    maxZoom: 18,
});
mvr.getTileUrl = function(coord) {
    var zoom = coord.z;
    var s = Math.pow(2, coord.z);
    var llp = L.point((coord.x * 256 + 128) / s, (coord.y * 256 + 128) / s);
    var ll = fromPointToLatLng(llp, s);
    var lng = ll.lng;    
    var lat = ll.lat;
    return "http://yumeblog.dip.jp/yb2g0.php?zoom=" + zoom + "&long=" + lng + "&lat=" + lat;
};
mvr.addTo(map);
function fromPointToLatLng(point, max_zoom) {
    var size = (1 << max_zoom) * 256,
        lat = (2 * Math.atan(Math.exp((point.y - size / 2) / -(size / (2 * Math.PI)))) - (Math.PI / 2)) * (180 / Math.PI),
        lng = (point.x - size / 2) * (360 / size);
    return L.latLng(lat, lng);
}
0
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
0
0