【问题标题】:GetTileUrl in GoogleMaps API is returning 404 ErrorGoogle Maps API 中的 GetTileUrl 返回 404 错误
【发布时间】:2015-10-19 11:50:45
【问题描述】:

我正在网页上使用 Google 地图。当我加载页面时,我在浏览器控制台上得到了这个:

GET http://tile.openstreetmap.org/0/1/0.png 404 (Not Found)

GET http://tile.openstreetmap.org/0/-1/0.png 404 (Not Found)

GET http://tile.openstreetmap.org/0/2/0.png 404 (Not Found)

GET http://tile.openstreetmap.org/0/-3/0.png 404 (Not Found)

GET http://tile.openstreetmap.org/0/-2/0.png 404 (Not Found)

GET http://tile.openstreetmap.org/0/-4/0.png 404 (Not Found)

GET http://tile.openstreetmap.org/0/3/0.png 404 (Not Found)

我试图调试这个,当调试器到达 GetTileUrl 方法时,坐标数组有时在 X / Y 中带有负值,所以,这就是它生成错误 URL 的原因。

有什么办法可以避免这个问题吗?我正在使用地图初始化添加我的 JS 代码。

var map;
var mgr;
var infowindow = new google.maps.InfoWindow();
function initialize() {
var myLatlng = new google.maps.LatLng(0, 0);
map = new google.maps.Map(document.getElementById("map"), {
center: myLatlng,
zoom: 12,
mapTypeId: "OSM",
mapTypeControl: false,
streetViewControl: false
});

map.mapTypes.set("OSM", 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),
name: "OpenStreetMap",
maxZoom: 18
}));
var marker0 = new google.maps.Marker({ map: map, position: new google.maps.LatLng(6.00945923805956, -77.05810546875), title: 'Quindío' });
google.maps.event.addListener(marker0, 'click', function() { infowindow.setContent('<div><a href="#" onclick="javascript: openRadWin(660); return false;"><img alt="Zoom" class="zoom" src="../../Content/img/zoom.png"/></a></div><iframe class="chart-thumbnail-iframe" width="240" height="200" src="ChartThumbnailViewer.aspx?rid=14&cid=59&mid=660" frameborder="0"></iframe>'); infowindow.open(map,marker0); }); 
var marker1 = new google.maps.Marker({ map: map, position: new google.maps.LatLng(-4.188574, -69.93929), title: 'Amazonas' });
google.maps.event.addListener(marker1, 'click', function() { infowindow.setContent('<div><a href="#" onclick="javascript: openRadWin(34); return false;"><img alt="Zoom" class="zoom" src="../../Content/img/zoom.png"/></a></div><iframe class="chart-thumbnail-iframe" width="240" height="200" src="ChartThumbnailViewer.aspx?rid=14&cid=59&mid=34" frameborder="0"></iframe>'); infowindow.open(map,marker1); }); 
var marker2 = new google.maps.Marker({ map: map, position: new google.maps.LatLng(5.5197222, -72.8875), title: 'Boyacá' });
google.maps.event.addListener(marker2, 'click', function() { infowindow.setContent('<div><a href="#" onclick="javascript: openRadWin(194); return false;"><img alt="Zoom" class="zoom" src="../../Content/img/zoom.png"/></a></div><iframe class="chart-thumbnail-iframe" width="240" height="200" src="ChartThumbnailViewer.aspx?rid=14&cid=59&mid=194" frameborder="0"></iframe>'); infowindow.open(map,marker2); }); 
var marker3 = new google.maps.Marker({ map: map, position: new google.maps.LatLng(1.3316667, -75.8822222), title: 'Caquetá' });
google.maps.event.addListener(marker3, 'click', function() { infowindow.setContent('<div><a href="#" onclick="javascript: openRadWin(284); return false;"><img alt="Zoom" class="zoom" src="../../Content/img/zoom.png"/></a></div><iframe class="chart-thumbnail-iframe" width="240" height="200" src="ChartThumbnailViewer.aspx?rid=14&cid=59&mid=284" frameborder="0"></iframe>'); infowindow.open(map,marker3); }); 
var marker4 = new google.maps.Marker({ map: map, position: new google.maps.LatLng(4.15, -73.65), title: 'Meta' });
google.maps.event.addListener(marker4, 'click', function() { infowindow.setContent('<div><a href="#" onclick="javascript: openRadWin(556); return false;"><img alt="Zoom" class="zoom" src="../../Content/img/zoom.png"/></a></div><iframe class="chart-thumbnail-iframe" width="240" height="200" src="ChartThumbnailViewer.aspx?rid=14&cid=59&mid=556" frameborder="0"></iframe>'); infowindow.open(map,marker4); }); 
var marker5 = new google.maps.Marker({ map: map, position: new google.maps.LatLng(5.7933333, -75.4308333), title: 'Antioquia' });
google.maps.event.addListener(marker5, 'click', function() { infowindow.setContent('<div><a href="#" onclick="javascript: openRadWin(36); return false;"><img alt="Zoom" class="zoom" src="../../Content/img/zoom.png"/></a></div><iframe class="chart-thumbnail-iframe" width="240" height="200" src="ChartThumbnailViewer.aspx?rid=14&cid=59&mid=36" frameborder="0"></iframe>'); infowindow.open(map,marker5); }); 
var marker6 = new google.maps.Marker({ map: map, position: new google.maps.LatLng(1.21, -77.26), title: 'Nariño' });
google.maps.event.addListener(marker6, 'click', function() { infowindow.setContent('<div><a href="#" onclick="javascript: openRadWin(574); return false;"><img alt="Zoom" class="zoom" src="../../Content/img/zoom.png"/></a></div><iframe class="chart-thumbnail-iframe" width="240" height="200" src="ChartThumbnailViewer.aspx?rid=14&cid=59&mid=574" frameborder="0"></iframe>'); infowindow.open(map,marker6); }); 
var marker7 = new google.maps.Marker({ map: map, position: new google.maps.LatLng(6.62641376843295, -70.9881591796875), title: 'Arauca' });
google.maps.event.addListener(marker7, 'click', function() { infowindow.setContent('<div><a href="#" onclick="javascript: openRadWin(135); return false;"><img alt="Zoom" class="zoom" src="../../Content/img/zoom.png"/></a></div><iframe class="chart-thumbnail-iframe" width="240" height="200" src="ChartThumbnailViewer.aspx?rid=14&cid=59&mid=135" frameborder="0"></iframe>'); infowindow.open(map,marker7); }); 
var marker8 = new google.maps.Marker({ map: map, position: new google.maps.LatLng(4.6, -74.0833333), title: 'Cundinamarca' });
google.maps.event.addListener(marker8, 'click', function() { infowindow.setContent('<div><a href="#" onclick="javascript: openRadWin(400); return false;"><img alt="Zoom" class="zoom" src="../../Content/img/zoom.png"/></a></div><iframe class="chart-thumbnail-iframe" width="240" height="200" src="ChartThumbnailViewer.aspx?rid=14&cid=59&mid=400" frameborder="0"></iframe>'); infowindow.open(map,marker8); }); 
var marker9 = new google.maps.Marker({ map: map, position: new google.maps.LatLng(4.43, -75.22), title: 'Tolima' });
google.maps.event.addListener(marker9, 'click', function() { infowindow.setContent('<div><a href="#" onclick="javascript: openRadWin(765); return false;"><img alt="Zoom" class="zoom" src="../../Content/img/zoom.png"/></a></div><iframe class="chart-thumbnail-iframe" width="240" height="200" src="ChartThumbnailViewer.aspx?rid=14&cid=59&mid=765" frameborder="0"></iframe>'); infowindow.open(map,marker9); }); 
var marker10 = new google.maps.Marker({ map: map, position: new google.maps.LatLng(7.1297222, -73.1258333), title: 'Santander' });
google.maps.event.addListener(marker10, 'click', function() { infowindow.setContent('<div><a href="#" onclick="javascript: openRadWin(691); return false;"><img alt="Zoom" class="zoom" src="../../Content/img/zoom.png"/></a></div><iframe class="chart-thumbnail-iframe" width="240" height="200" src="ChartThumbnailViewer.aspx?rid=14&cid=59&mid=691" frameborder="0"></iframe>'); infowindow.open(map,marker10); }); 
var marker11 = new google.maps.Marker({ map: map, position: new google.maps.LatLng(3.4372222, -76.5225), title: 'Valle Del Cauca' });
google.maps.event.addListener(marker11, 'click', function() { infowindow.setContent('<div><a href="#" onclick="javascript: openRadWin(809); return false;"><img alt="Zoom" class="zoom" src="../../Content/img/zoom.png"/></a></div><iframe class="chart-thumbnail-iframe" width="240" height="200" src="ChartThumbnailViewer.aspx?rid=14&cid=59&mid=809" frameborder="0"></iframe>'); infowindow.open(map,marker11); }); 
var marker12 = new google.maps.Marker({ map: map, position: new google.maps.LatLng(0, -76.1572265625), title: 'Putumayo' });
google.maps.event.addListener(marker12, 'click', function() { infowindow.setContent('<div><a href="#" onclick="javascript: openRadWin(651); return false;"><img alt="Zoom" class="zoom" src="../../Content/img/zoom.png"/></a></div><iframe class="chart-thumbnail-iframe" width="240" height="200" src="ChartThumbnailViewer.aspx?rid=14&cid=59&mid=651" frameborder="0"></iframe>'); infowindow.open(map,marker12); }); 
var marker13 = new google.maps.Marker({ map: map, position: new google.maps.LatLng(5.35, -72.3833333), title: 'Casanare' });
google.maps.event.addListener(marker13, 'click', function() { infowindow.setContent('<div><a href="#" onclick="javascript: openRadWin(296); return false;"><img alt="Zoom" class="zoom" src="../../Content/img/zoom.png"/></a></div><iframe class="chart-thumbnail-iframe" width="240" height="200" src="ChartThumbnailViewer.aspx?rid=14&cid=59&mid=296" frameborder="0"></iframe>'); infowindow.open(map,marker13); }); 
var marker14 = new google.maps.Marker({ map: map, position: new google.maps.LatLng(2.460181181021, -75.60791015625), title: 'Huila' });
google.maps.event.addListener(marker14, 'click', function() { infowindow.setContent('<div><a href="#" onclick="javascript: openRadWin(494); return false;"><img alt="Zoom" class="zoom" src="../../Content/img/zoom.png"/></a></div><iframe class="chart-thumbnail-iframe" width="240" height="200" src="ChartThumbnailViewer.aspx?rid=14&cid=59&mid=494" frameborder="0"></iframe>'); infowindow.open(map,marker14); }); 
var marker15 = new google.maps.Marker({ map: map, position: new google.maps.LatLng(1.25, -70.21667), title: 'Vaupes' });
google.maps.event.addListener(marker15, 'click', function() { infowindow.setContent('<div><a href="#" onclick="javascript: openRadWin(848); return false;"><img alt="Zoom" class="zoom" src="../../Content/img/zoom.png"/></a></div><iframe class="chart-thumbnail-iframe" width="240" height="200" src="ChartThumbnailViewer.aspx?rid=14&cid=59&mid=848" frameborder="0"></iframe>'); infowindow.open(map,marker15); }); 
var marker16 = new google.maps.Marker({ map: map, position: new google.maps.LatLng(6.184765, -67.488503), title: 'Vichada' });
google.maps.event.addListener(marker16, 'click', function() { infowindow.setContent('<div><a href="#" onclick="javascript: openRadWin(850); return false;"><img alt="Zoom" class="zoom" src="../../Content/img/zoom.png"/></a></div><iframe class="chart-thumbnail-iframe" width="240" height="200" src="ChartThumbnailViewer.aspx?rid=14&cid=59&mid=850" frameborder="0"></iframe>'); infowindow.open(map,marker16); }); 
var latlngbounds = new google.maps.LatLngBounds();
latlngbounds.extend(new google.maps.LatLng(6.00945923805956, -77.05810546875));
latlngbounds.extend(new google.maps.LatLng(-4.188574, -69.93929));
latlngbounds.extend(new google.maps.LatLng(5.5197222, -72.8875));
latlngbounds.extend(new google.maps.LatLng(1.3316667, -75.8822222));
latlngbounds.extend(new google.maps.LatLng(4.15, -73.65));
latlngbounds.extend(new google.maps.LatLng(5.7933333, -75.4308333));
latlngbounds.extend(new google.maps.LatLng(1.21, -77.26));
latlngbounds.extend(new google.maps.LatLng(6.62641376843295, -70.9881591796875));
latlngbounds.extend(new google.maps.LatLng(4.6, -74.0833333));
latlngbounds.extend(new google.maps.LatLng(4.43, -75.22));
latlngbounds.extend(new google.maps.LatLng(7.1297222, -73.1258333));
latlngbounds.extend(new google.maps.LatLng(3.4372222, -76.5225));
latlngbounds.extend(new google.maps.LatLng(0, -76.1572265625));
latlngbounds.extend(new google.maps.LatLng(5.35, -72.3833333));
latlngbounds.extend(new google.maps.LatLng(2.460181181021, -75.60791015625));
latlngbounds.extend(new google.maps.LatLng(1.25, -70.21667));
latlngbounds.extend(new google.maps.LatLng(6.184765, -67.488503));
map.fitBounds(latlngbounds);
new google.maps.Rectangle({
bounds: latlngbounds, map: map, fillOpacity: 0, strokeWeight: 0
});
}
google.maps.event.addDomListener(window,'load',initialize);
html, body, #map {
  width: 100%;
  height: 100%;
  }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js"></script>
<div id="map"></div>

【问题讨论】:

    标签: javascript jquery google-maps http-status-code-404 openstreetmap


    【解决方案1】:

    你需要一个getNormalizeCoordinate,就像this example in the documentation一样

    // Normalizes the coords that tiles repeat across the x axis (horizontally)
    // like the standard Google map tiles.
    function getNormalizedCoord(coord, zoom) {
      var y = coord.y;
      var x = coord.x;
    
      // tile range in one direction range is dependent on zoom level
      // 0 = 1 tile, 1 = 2 tiles, 2 = 4 tiles, 3 = 8 tiles, etc
      var tileRange = 1 << zoom;
    
      // don't repeat across y-axis (vertically)
      if (y < 0 || y >= tileRange) {
        return null;
      }
    
      // repeat across x-axis
      if (x < 0 || x >= tileRange) {
        x = (x % tileRange + tileRange) % tileRange;
      }
    
      return {
        x: x,
        y: y
      };
    }
    

    代码 sn-p:

    var map;
    var mgr;
    var infowindow = new google.maps.InfoWindow();
    function initialize() {
    var myLatlng = new google.maps.LatLng(0, 0);
    map = new google.maps.Map(document.getElementById("map"), {
    center: myLatlng,
    zoom: 12,
    mapTypeId: "OSM",
    mapTypeControl: false,
    streetViewControl: false
    });
    
    map.mapTypes.set("OSM", new google.maps.ImageMapType({
    getTileUrl: function(coord, zoom) {
          var normalizedCoord = getNormalizedCoord(coord, zoom);
          if (!normalizedCoord) {
            return null;
          }
          var bound = Math.pow(2, zoom);
          return "http://tile.openstreetmap.org/" + zoom + "/" + normalizedCoord.x + "/" + normalizedCoord.y + ".png";
    },
    tileSize: new google.maps.Size(256, 256),
    name: "OpenStreetMap",
    maxZoom: 18
    }));
    var marker0 = new google.maps.Marker({ map: map, position: new google.maps.LatLng(6.00945923805956, -77.05810546875), title: 'Quindío' });
    google.maps.event.addListener(marker0, 'click', function() { infowindow.setContent('<div><a href="#" onclick="javascript: openRadWin(660); return false;"><img alt="Zoom" class="zoom" src="../../Content/img/zoom.png"/></a></div><iframe class="chart-thumbnail-iframe" width="240" height="200" src="ChartThumbnailViewer.aspx?rid=14&cid=59&mid=660" frameborder="0"></iframe>'); infowindow.open(map,marker0); }); 
    var marker1 = new google.maps.Marker({ map: map, position: new google.maps.LatLng(-4.188574, -69.93929), title: 'Amazonas' });
    google.maps.event.addListener(marker1, 'click', function() { infowindow.setContent('<div><a href="#" onclick="javascript: openRadWin(34); return false;"><img alt="Zoom" class="zoom" src="../../Content/img/zoom.png"/></a></div><iframe class="chart-thumbnail-iframe" width="240" height="200" src="ChartThumbnailViewer.aspx?rid=14&cid=59&mid=34" frameborder="0"></iframe>'); infowindow.open(map,marker1); }); 
    var marker2 = new google.maps.Marker({ map: map, position: new google.maps.LatLng(5.5197222, -72.8875), title: 'Boyacá' });
    google.maps.event.addListener(marker2, 'click', function() { infowindow.setContent('<div><a href="#" onclick="javascript: openRadWin(194); return false;"><img alt="Zoom" class="zoom" src="../../Content/img/zoom.png"/></a></div><iframe class="chart-thumbnail-iframe" width="240" height="200" src="ChartThumbnailViewer.aspx?rid=14&cid=59&mid=194" frameborder="0"></iframe>'); infowindow.open(map,marker2); }); 
    var marker3 = new google.maps.Marker({ map: map, position: new google.maps.LatLng(1.3316667, -75.8822222), title: 'Caquetá' });
    google.maps.event.addListener(marker3, 'click', function() { infowindow.setContent('<div><a href="#" onclick="javascript: openRadWin(284); return false;"><img alt="Zoom" class="zoom" src="../../Content/img/zoom.png"/></a></div><iframe class="chart-thumbnail-iframe" width="240" height="200" src="ChartThumbnailViewer.aspx?rid=14&cid=59&mid=284" frameborder="0"></iframe>'); infowindow.open(map,marker3); }); 
    var marker4 = new google.maps.Marker({ map: map, position: new google.maps.LatLng(4.15, -73.65), title: 'Meta' });
    google.maps.event.addListener(marker4, 'click', function() { infowindow.setContent('<div><a href="#" onclick="javascript: openRadWin(556); return false;"><img alt="Zoom" class="zoom" src="../../Content/img/zoom.png"/></a></div><iframe class="chart-thumbnail-iframe" width="240" height="200" src="ChartThumbnailViewer.aspx?rid=14&cid=59&mid=556" frameborder="0"></iframe>'); infowindow.open(map,marker4); }); 
    var marker5 = new google.maps.Marker({ map: map, position: new google.maps.LatLng(5.7933333, -75.4308333), title: 'Antioquia' });
    google.maps.event.addListener(marker5, 'click', function() { infowindow.setContent('<div><a href="#" onclick="javascript: openRadWin(36); return false;"><img alt="Zoom" class="zoom" src="../../Content/img/zoom.png"/></a></div><iframe class="chart-thumbnail-iframe" width="240" height="200" src="ChartThumbnailViewer.aspx?rid=14&cid=59&mid=36" frameborder="0"></iframe>'); infowindow.open(map,marker5); }); 
    var marker6 = new google.maps.Marker({ map: map, position: new google.maps.LatLng(1.21, -77.26), title: 'Nariño' });
    google.maps.event.addListener(marker6, 'click', function() { infowindow.setContent('<div><a href="#" onclick="javascript: openRadWin(574); return false;"><img alt="Zoom" class="zoom" src="../../Content/img/zoom.png"/></a></div><iframe class="chart-thumbnail-iframe" width="240" height="200" src="ChartThumbnailViewer.aspx?rid=14&cid=59&mid=574" frameborder="0"></iframe>'); infowindow.open(map,marker6); }); 
    var marker7 = new google.maps.Marker({ map: map, position: new google.maps.LatLng(6.62641376843295, -70.9881591796875), title: 'Arauca' });
    google.maps.event.addListener(marker7, 'click', function() { infowindow.setContent('<div><a href="#" onclick="javascript: openRadWin(135); return false;"><img alt="Zoom" class="zoom" src="../../Content/img/zoom.png"/></a></div><iframe class="chart-thumbnail-iframe" width="240" height="200" src="ChartThumbnailViewer.aspx?rid=14&cid=59&mid=135" frameborder="0"></iframe>'); infowindow.open(map,marker7); }); 
    var marker8 = new google.maps.Marker({ map: map, position: new google.maps.LatLng(4.6, -74.0833333), title: 'Cundinamarca' });
    google.maps.event.addListener(marker8, 'click', function() { infowindow.setContent('<div><a href="#" onclick="javascript: openRadWin(400); return false;"><img alt="Zoom" class="zoom" src="../../Content/img/zoom.png"/></a></div><iframe class="chart-thumbnail-iframe" width="240" height="200" src="ChartThumbnailViewer.aspx?rid=14&cid=59&mid=400" frameborder="0"></iframe>'); infowindow.open(map,marker8); }); 
    var marker9 = new google.maps.Marker({ map: map, position: new google.maps.LatLng(4.43, -75.22), title: 'Tolima' });
    google.maps.event.addListener(marker9, 'click', function() { infowindow.setContent('<div><a href="#" onclick="javascript: openRadWin(765); return false;"><img alt="Zoom" class="zoom" src="../../Content/img/zoom.png"/></a></div><iframe class="chart-thumbnail-iframe" width="240" height="200" src="ChartThumbnailViewer.aspx?rid=14&cid=59&mid=765" frameborder="0"></iframe>'); infowindow.open(map,marker9); }); 
    var marker10 = new google.maps.Marker({ map: map, position: new google.maps.LatLng(7.1297222, -73.1258333), title: 'Santander' });
    google.maps.event.addListener(marker10, 'click', function() { infowindow.setContent('<div><a href="#" onclick="javascript: openRadWin(691); return false;"><img alt="Zoom" class="zoom" src="../../Content/img/zoom.png"/></a></div><iframe class="chart-thumbnail-iframe" width="240" height="200" src="ChartThumbnailViewer.aspx?rid=14&cid=59&mid=691" frameborder="0"></iframe>'); infowindow.open(map,marker10); }); 
    var marker11 = new google.maps.Marker({ map: map, position: new google.maps.LatLng(3.4372222, -76.5225), title: 'Valle Del Cauca' });
    google.maps.event.addListener(marker11, 'click', function() { infowindow.setContent('<div><a href="#" onclick="javascript: openRadWin(809); return false;"><img alt="Zoom" class="zoom" src="../../Content/img/zoom.png"/></a></div><iframe class="chart-thumbnail-iframe" width="240" height="200" src="ChartThumbnailViewer.aspx?rid=14&cid=59&mid=809" frameborder="0"></iframe>'); infowindow.open(map,marker11); }); 
    var marker12 = new google.maps.Marker({ map: map, position: new google.maps.LatLng(0, -76.1572265625), title: 'Putumayo' });
    google.maps.event.addListener(marker12, 'click', function() { infowindow.setContent('<div><a href="#" onclick="javascript: openRadWin(651); return false;"><img alt="Zoom" class="zoom" src="../../Content/img/zoom.png"/></a></div><iframe class="chart-thumbnail-iframe" width="240" height="200" src="ChartThumbnailViewer.aspx?rid=14&cid=59&mid=651" frameborder="0"></iframe>'); infowindow.open(map,marker12); }); 
    var marker13 = new google.maps.Marker({ map: map, position: new google.maps.LatLng(5.35, -72.3833333), title: 'Casanare' });
    google.maps.event.addListener(marker13, 'click', function() { infowindow.setContent('<div><a href="#" onclick="javascript: openRadWin(296); return false;"><img alt="Zoom" class="zoom" src="../../Content/img/zoom.png"/></a></div><iframe class="chart-thumbnail-iframe" width="240" height="200" src="ChartThumbnailViewer.aspx?rid=14&cid=59&mid=296" frameborder="0"></iframe>'); infowindow.open(map,marker13); }); 
    var marker14 = new google.maps.Marker({ map: map, position: new google.maps.LatLng(2.460181181021, -75.60791015625), title: 'Huila' });
    google.maps.event.addListener(marker14, 'click', function() { infowindow.setContent('<div><a href="#" onclick="javascript: openRadWin(494); return false;"><img alt="Zoom" class="zoom" src="../../Content/img/zoom.png"/></a></div><iframe class="chart-thumbnail-iframe" width="240" height="200" src="ChartThumbnailViewer.aspx?rid=14&cid=59&mid=494" frameborder="0"></iframe>'); infowindow.open(map,marker14); }); 
    var marker15 = new google.maps.Marker({ map: map, position: new google.maps.LatLng(1.25, -70.21667), title: 'Vaupes' });
    google.maps.event.addListener(marker15, 'click', function() { infowindow.setContent('<div><a href="#" onclick="javascript: openRadWin(848); return false;"><img alt="Zoom" class="zoom" src="../../Content/img/zoom.png"/></a></div><iframe class="chart-thumbnail-iframe" width="240" height="200" src="ChartThumbnailViewer.aspx?rid=14&cid=59&mid=848" frameborder="0"></iframe>'); infowindow.open(map,marker15); }); 
    var marker16 = new google.maps.Marker({ map: map, position: new google.maps.LatLng(6.184765, -67.488503), title: 'Vichada' });
    google.maps.event.addListener(marker16, 'click', function() { infowindow.setContent('<div><a href="#" onclick="javascript: openRadWin(850); return false;"><img alt="Zoom" class="zoom" src="../../Content/img/zoom.png"/></a></div><iframe class="chart-thumbnail-iframe" width="240" height="200" src="ChartThumbnailViewer.aspx?rid=14&cid=59&mid=850" frameborder="0"></iframe>'); infowindow.open(map,marker16); }); 
    var latlngbounds = new google.maps.LatLngBounds();
    latlngbounds.extend(new google.maps.LatLng(6.00945923805956, -77.05810546875));
    latlngbounds.extend(new google.maps.LatLng(-4.188574, -69.93929));
    latlngbounds.extend(new google.maps.LatLng(5.5197222, -72.8875));
    latlngbounds.extend(new google.maps.LatLng(1.3316667, -75.8822222));
    latlngbounds.extend(new google.maps.LatLng(4.15, -73.65));
    latlngbounds.extend(new google.maps.LatLng(5.7933333, -75.4308333));
    latlngbounds.extend(new google.maps.LatLng(1.21, -77.26));
    latlngbounds.extend(new google.maps.LatLng(6.62641376843295, -70.9881591796875));
    latlngbounds.extend(new google.maps.LatLng(4.6, -74.0833333));
    latlngbounds.extend(new google.maps.LatLng(4.43, -75.22));
    latlngbounds.extend(new google.maps.LatLng(7.1297222, -73.1258333));
    latlngbounds.extend(new google.maps.LatLng(3.4372222, -76.5225));
    latlngbounds.extend(new google.maps.LatLng(0, -76.1572265625));
    latlngbounds.extend(new google.maps.LatLng(5.35, -72.3833333));
    latlngbounds.extend(new google.maps.LatLng(2.460181181021, -75.60791015625));
    latlngbounds.extend(new google.maps.LatLng(1.25, -70.21667));
    latlngbounds.extend(new google.maps.LatLng(6.184765, -67.488503));
    map.fitBounds(latlngbounds);
    new google.maps.Rectangle({
    bounds: latlngbounds, map: map, fillOpacity: 0, strokeWeight: 0
    });
    }
    google.maps.event.addDomListener(window,'load',initialize);
    
    // Normalizes the coords that tiles repeat across the x axis (horizontally)
    // like the standard Google map tiles.
    function getNormalizedCoord(coord, zoom) {
      var y = coord.y;
      var x = coord.x;
    
      // tile range in one direction range is dependent on zoom level
      // 0 = 1 tile, 1 = 2 tiles, 2 = 4 tiles, 3 = 8 tiles, etc
      var tileRange = 1 << zoom;
    
      // don't repeat across y-axis (vertically)
      if (y < 0 || y >= tileRange) {
        return null;
      }
    
      // repeat across x-axis
      if (x < 0 || x >= tileRange) {
        x = (x % tileRange + tileRange) % tileRange;
      }
    
      return {
        x: x,
        y: y
      };
    }
    body, html, #map {
      height: 100%;
      width: 100%;
      }
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js"></script>
    <div id="map"></div>

    【讨论】:

    • 您好,我尝试了这种方法,归一化坐标始终为 (0,0),缩放也以 0 的形式到达 getTileUrl,它不起作用:( 谢谢
    • 它对我有用。您是否将您的代码与此答案中的工作代码 sn-p 进行了比较?
    猜你喜欢
    • 1970-01-01
    • 2021-11-02
    • 2013-01-12
    • 1970-01-01
    • 1970-01-01
    • 2012-06-05
    • 2016-08-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多