Geseco深度层的谷歌地图Wms错误的Openseamap

时间:2018-05-14 18:46:26

标签: google-maps google-maps-api-3 openstreetmap openseamap

我正在尝试在Google地图上放置一些基于OSM的图层。项目名称为openseamap。到目前为止它一直工作,直到缩放8.但是在缩放8之后我得到400错误,其中说" 400:X,T,索引的Y值被计算为{120.99999999902559,155.83725643764348},其必须舍入为{ 121,156}并超过10%的门槛。也许客户使用的是错误的来源?"

var gebcoLayer =
                new google.maps.ImageMapType(
                    {

                        getTileUrl: function (coord, zoom) {
                            // Compose URL for overlay tile
                            var tilesPerGlobe = 1 << zoom;
                            var x = coord.x % tilesPerGlobe;
                            if (x < 0) {
                                x = tilesPerGlobe + x;
                            }
                            var s = Math.pow(2, zoom);
                            var twidth = 256;
                            var theight = 256;


                            var gBl = map.getProjection().fromPointToLatLng(new google.maps.Point(x * twidth / s, (coord.y + 1) * theight / s)); // bottom left / SW
                            var gTr = map.getProjection().fromPointToLatLng(new google.maps.Point((x + 1) * twidth / s, coord.y * theight / s)); // top right / NE



                            var mercator1 = Conv.ll2m(gBl.lng(), gBl.lat());
                            var mercator2 = Conv.ll2m(gTr.lng(), gTr.lat());


                            var bbox2 = mercator1.x + "," + mercator1.y + "," + mercator2.x + "," + mercator2.y;                           


                            var url = "http://osm.franken.de:8080/geoserver/gwc/service/wms?LAYERS=gebco_2014&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&SRS=EPSG%3A900913&BBOX=" + bbox2 + "&WIDTH=256&HEIGHT=256";
                            return url;
                        },
                        tileSize: new google.maps.Size(256, 256),
                        name: "Gebco",
                        isPng: true,
                        //maxZoom: 18,
                        opacity: 0.3,
                    });
            map.overlayMapTypes.insertAt(0, gebcoLayer);

我没有在这里输入整个代码,而是创造了一个小提琴。 Here is my fiddle!

正如你可以在小提琴中看到的那样,如果缩放值小于8,它可以正常工作。我无法找出导致此错误的原因。我假设osm和谷歌之间的缩放级别差异?还是我计算bbox值的方式?

0 个答案:

没有答案