Replacing GTileLayer in Google Maps v3, with ImageMapType, Tile bounding box?

后端 未结 3 1451
陌清茗
陌清茗 2021-02-03 15:21

I need to update this code:

radar_layer.getTileUrl=function(tile,zoom) {

    var llp = new GPoint(tile.x*256,(tile.y+1)*256);
    var urp = new         


        
3条回答
  •  南旧
    南旧 (楼主)
    2021-02-03 16:11

    Thank you for the details. In fact in my case I couldn't change the API to use tiles number I need to pass LatLng. I found this solution... so far it works for me:

    var myMapOptions = {
              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));
                url = "/layer/layer_"+zoom+"_"+top.lng().toFixed(6)+"_"+bot.lat().toFixed(6)+"_"+bot.lng().toFixed(6)+"_"+top.lat().toFixed(6)+".png";
            return url; 
           },
          tileSize: new google.maps.Size(256, 256),
          isPng: true,
          opacity: 0.4
         }
    

提交回复
热议问题