0

I'm kinda new to OpenLayers and I would like to ask whats the problem in my code. This is actually just from the examples I got from the internet but I seem can't make it work. All I want to do is to make POIs using Openlayers.layers.text.

map = new OpenLayers.Map("mapdiv");
map.addLayer(new OpenLayers.Layer.OSM());
var pois = new OpenLayers.Layer.Text( "My Points",
                { location:"./textfile.txt",
                  projection: map.displayProjection
                });
map.addLayer(pois);

and in my textfile is

lat lon title   description iconSize    iconOffset  icon
10  20  title   description 21,25   -10,-25 http://www.openlayers.org/dev/img/marker.png

I've been trying to figure out whats wrong with my codes all day but i cant make it work. Can anyone help me to figure out whats wrong with my code? only the map will be shown with no popup/marker..

4

1 回答 1

0

确保您的textfile.txt文件符合以下要求:

  • 数据文件的第一行应该是带有数据列名的标题行。每列应由tab空格分隔。
  • 最后一行textfile.txt应该是一个空字符串。
  • textfile.txt应放置在与原始应用程序相同的主机上。
  • OpenLayers.Layer.Text如果您尝试从文件系统运行应用程序,则不起作用。使用网络服务器。

看我的现场演示。.txt 文件示例:在此处输入图像描述

于 2012-12-19T04:26:24.363 回答