关于Google地图上的WMS图层

时间:2018-06-07 15:16:57

标签: api maps wms

我从documentation

学习
var map;
var josefov = new google.maps.LatLng(49.3119, 16.67029);
var osmMapType = new google.maps.ImageMapType({
                        getTileUrl: function (coord, zoom) { return "http://tile.openstreetmap.org/" + zoom + "/" + coord.x + "/" + coord.y + ".png";},
    tileSize: new google.maps.Size(256, 256),
    isPng: true,
    //alt: "OpenStreetMap",
    name: "OSM",
    maxZoom: 19
    });
    var SLPLayer = new google.maps.ImageMapType({
                  getTileUrl: function (coord, zoom) {
                   var proj = map.getProjection();
                   var zfactor = Math.pow(2, zoom);
                   var top = proj.fromPointToLatLng(new google.maps.Point(coord.x * 256 / zfactor, coord.y * 256 / zfactor));
                   var bot = proj.fromPointToLatLng(new google.maps.Point((coord.x + 1) * 256 / zfactor, (coord.y + 1) * 256 / zfactor));
                            //var deltaX = 0.0013;
                            //var deltaY = 0.00058;
                            var bbox = top.lng() + "," +  bot.lat() + "," +  bot.lng() + "," +  top.lat();

                            //base WMS URL
                            var url = "http://gis.sinica.edu.tw/tileserver/wmts?";
                            url += "SERVICE=WMTS";    //WMS service
                            url += "&REQUEST=GetTile";  //WMS version  
                            url += "&VERSION=1.0.0"; //WMS layers
                            url += "&LAYER=JM20K_1904" ; //WMS format
                            url += "&TILEMATRIXSET=GoogleMapsCompatible";  
                            url += "&TILEMATRIX=12";
                            url += "&TILEROW=1753";     //set WGS84 
                            url += "&TILECOL=3430";      // set bounding box
                            url += "&FORMAT=image/jpeg";
                            url += "&WIDTH=256";         //tile size in google
                            url += "&HEIGHT=256";
                            return url;                 
                        },
                        tileSize: new google.maps.Size(256, 256),
                        isPng: true
                    });
    function initialize() {
            var mapOptions = {
                zoom: 17,
                center: josefov,
                mapTypeId: 'OSM',
                mapTypeControlOptions: {
                    mapTypeIds: ['OSM', google.maps.MapTypeId.ROADMAP, google.maps.MapTypeId.SATELLITE, google.maps.MapTypeId.HYBRID, google.maps.MapTypeId.TERRAIN],
                    style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
                }
            };
            map = new google.maps.Map(document.getElementById("map"), mapOptions);
            map.mapTypes.set('OSM', osmMapType);
            map.setMapTypeId(google.maps.MapTypeId.ROADMAP);
            //add WMS layer
            map.overlayMapTypes.push(SLPLayer);
    }

我的形象也是无限延伸

enter link description here

我的来源:

https://i.stack.imgur.com/MBVur.jpg

view-source:http://www.sumbera.com/lab/GoogleV3/tiledWMSoverlayGoogleV3.htm

我期望的结果只有一个。 请教我怎么做。谢谢。

0 个答案:

没有答案