2017-02-19 47 views

回答

5

对于谷歌的卫星数据,你可以用TileImage源去, 指定模式的URL:

var map = new ol.Map({ 
 
     layers: [ 
 
      new ol.layer.Tile({ 
 
      source: new ol.source.TileImage({url: 'http://khm0.googleapis.com/kh?v=717&hl=pl&&x={x}&y={y}&z={z}'}) 
 
      }) 
 
     ], 
 
     target: 'map', 
 
     view: new ol.View({ 
 
      center: ol.proj.fromLonLat([19.2, 52]), 
 
      zoom: 6 
 
     }) 
 
\t \t });

编辑: 对于谷歌的平原地图数据,您可以用TileImage源去, 指定pb参数部分的模式url:

var map = new ol.Map({ 
 
     layers: [ 
 
      new ol.layer.Tile({ 
 
      source: new ol.source.TileImage({url: 'http://maps.google.com/maps/vt?pb=!1m5!1m4!1i{z}!2i{x}!3i{y}!4i256!2m3!1e0!2sm!3i375060738!3m9!2spl!3sUS!5e18!12m1!1e47!12m3!1e37!2m1!1ssmartmaps!4e0'}) 
 
      }) 
 
     ], 
 
     target: 'map', 
 
     view: new ol.View({ 
 
      center: ol.proj.fromLonLat([19.2, 52]), 
 
      zoom: 6 
 
     }) 
 
\t \t });

+1

或者是,更容易与地址在OL3答案中给出: http://stackoverflow.com/a/33993878/6068293 –

+7

直接访问这样的磁贴可能违反了Google的服务条款。 https://developers.google.com/maps/terms部分10.1.a – Rob

4

的OpenLayers有使用API​​,它们用于OL2和OL3的书面同意。由于所述api经常发生的问题,对它的支持停止了。

我们是不允许直接使用瓷砖,答案是不合法的。

但是,您也可以使用谷歌的地图API,并用它编写自己的OL源实现或使用现有的附加像ol3-google-maps

更多信息可以在这里找到:https://github.com/openlayers/openlayers/issues/2205