Skip to main content
2 of 5
added 367 characters in body
Vikash Talanki
  • 993
  • 1
  • 11
  • 23

points on google layer using openlayers

HI,

I want to load some points, whose lat-long values are saved in a .txt file over google maps. The following is the code which I am using for the same. The google map layer is succesfully loaded if I keep lines 1-10 & 13-17. For loading the data points I am including 11-12 lines but I am not getting any output at all. I request you to please find the error and suggest how to do the same. "data.txt" contains the lat-long values with tab delimited present in my server. 

1.<html>
2.<head> 
3.<title>OpenLayers Example</title> 
4.<script src="http://openlayers.org/api/OpenLayers.js"></script> 
5.</head> 
6.<body> 
7.<div style="width:100%; height:100%" id="map"></div> 
8.<script defer="defer" type="text/javascript"> 
9.   var map = new OpenLayers.Map('map'); 
10.  var gmaplayer = new OpenLayers.Layer.Google( "Google Streets", 
       "http://maps.google.com/mapsfile=api&v=2&key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhR_wWLPFku8Ix9i2SXYRVK3e45q1BQUd_beF8dtzKET_EteAjPdGDwqpQ"); 

11.  var layer = new OpenLayers.Layer.GML("Layer Name","http://localhost/data.txt", 
        {format: OpenLayers.Format.Text }); 
12.   map.addLayer(layer); 
13.   map.addLayer(gmaplayer); 
14.   map.zoomToMaxExtent(); 
15.</script> 
16.</body> 
17.</html> 

When I am replacing above 11-12 lines with 
11.var pois = new OpenLayers.Layer.Text( "My Points", 
                { location:"./data.txt", 
                  projection: map.displayProjection 
                }); 
12.map.addLayer(pois);
Even then I am not able to get the output. I require some needful help from any one of you
Vikash Talanki
  • 993
  • 1
  • 11
  • 23