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()
])
});
答
谢谢。我解决了它。我链接到IP直接添加'osm_tiles/{z}/{x}/{y} .png'