2017-09-18 190 views
0

晚上好:EC2開放街道地圖服務器與打開圖層3

我想用打開圖層連接到我的EC2開放街道地圖服務器3. 所以,我在服務器上也有文件,例如:

http://ec2-34-240-39-198.eu-west-1.compute.amazonaws.com/openlayers-example.html

然而,我的代碼不顯示的地址,如果你表現出的來源(按Ctrl-U):

var newL = new OpenLayers.Layer.OSM("Default", "/osm_tiles/${z}/${x}/${y}.png", {numZoomLevels: 19}); 

我不知道是什麼是「默認」,和我不能用打開圖層3 連接我的服務器這是我的代碼:

var map = new ol.Map({ 
      target: 'map', 
      renderer: 'canvas', 
      layers: [ 
      new ol.layer.Tile({ 
       source: new ol.source.OSM({ 
        crossOrigin: null, 
        url: 'http://ec2-34-240-39-198.eu-west-1.compute.amazonaws.com/osm_tiles/${z}/${x}/${y}.png', 
        }), 
       }), 
       vectorLayer, 
      ], 
// Create a view centered on the specified location and zoom level 
view: new ol.View({ 
     center: ol.proj.transform([2.1833, 41.3833], 'EPSG:4326', 'EPSG:3857'), 
     zoom: 3 
     }), 
     interactions: ol.interaction.defaults().extend([ 
     new ol.interaction.DragRotateAndZoom() 
      ]) 
     }); 

回答

1

它連接到你的服務器。源顯示通用位置。 Open Layer處理所有的複雜性以找到適當的X/Y/Z值。

您可以右鍵點擊地圖並顯示圖片信息。您將看到它們確實來自您的服務器,具有不同的X/Y/Z值。

enter image description here

0

謝謝。我解決了它。我鏈接到IP直接添加'osm_tiles/{z}/{x}/{y} .png'

相關問題