代码之家  ›  专栏  ›  技术社区  ›  Miguel Herreros Cejas

EC2具有开放层3的开放街道地图服务器

  •  0
  • Miguel Herreros Cejas  · 技术社区  · 7 年前

    晚上好:

    我想用开放层3连接到我的EC2开放街道地图服务器。

    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});
    

    这是我的代码:

    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()
              ])
            });
    
    2 回复  |  直到 7 年前
        1
  •  1
  •   JGH    7 年前

    它正在连接到您的服务器。来源显示了通用位置。开放层处理所有复杂度,以找到适当的X/Y/Z值。

    您可以右键单击地图并显示图片信息。您将看到它们确实来自您的服务器,具有不同的X/Y/Z值。

    enter image description here

        2
  •  0
  •   Miguel Herreros Cejas    7 年前