【问题标题】:Add image to openlayers map将图像添加到 openlayers 地图
【发布时间】:2013-01-28 16:32:54
【问题描述】:

这是我在 openlayers 地图上添加图像的代码。

var image = new OpenLayers.Layer.Image(
    'Image 1',
    'http://belocalat.com/wp-content/plugins/openlayers/data/baselayer-img1.png',
    //new OpenLayers.Bounds(27.418100,35.771100,28.388000,36.558500),
    new OpenLayers.Size(800,255),
    {isBaseLayer: false}
 );

map.addLayer(image);

但是,我无法在 openlayers 上显示图像。 谁能给我解决方案?

提前致谢。

【问题讨论】:

  • 为什么线设置bounds被注释掉了?
  • 如果我删除评论它不起作用..你有什么解决方案吗?

标签: javascript map openlayers


【解决方案1】:

我已经尝试了以下代码并且它已经工作了。从fiddle 结帐。不要忘记从 layerswitcher 中选择 Image layer。

var osm = new OpenLayers.Layer.OSM();

var graphic = new OpenLayers.Layer.Image(
    'Image',
    'http://belocalat.com/wp-content/plugins/openlayers/data/baselayer-img1.png',
    new OpenLayers.Bounds(27.418100,35.771100,28.388000,36.558500),
    new OpenLayers.Size(800,255),
    {numZoomLevels: 3}
);

map.addControl(new OpenLayers.Control.LayerSwitcher());
map.addLayers([osm, graphic]);
map.zoomToExtent(new OpenLayers.Bounds(27.418100,35.771100,28.388000,36.558500));

希望对你有帮助……

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-04-01
    • 2017-04-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-27
    • 1970-01-01
    相关资源
    最近更新 更多