I used a text file including some points in below code, but it just could read the first point!!
<html><body>
<div id="mapdiv"></div>
<script src="http://ift.tt/SKQfnh"></script>
<script>
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);
var layer_switcher= new OpenLayers.Control.LayerSwitcher({});
map.addControl(layer_switcher);
var lat = 29.35387;
var lon = 52.43609;
var zoom = 5;
var fromProjection = new OpenLayers.Projection("EPSG:4326"); // Transform from WGS 1984
var toProjection = new OpenLayers.Projection("EPSG:900913"); // to Spherical Mercator Projection
var position = new OpenLayers.LonLat(lon, lat).transform( fromProjection, toProjection);
map.setCenter(position, zoom);
</script>
</body></html>
How can it read all the points in textfile? textfile :
lat lon title description icon iconSize iconOffset
48.9459301 9.6075669 Title One Description one. ./Ol_icon_blue_example.png 24,24 0,-24
53.9899851 35.5382032 Title Two Description two. ./Ol_icon_red_example.png 16,16 -8,-8
Aucun commentaire:
Enregistrer un commentaire