[OpenLayers-Users] OpenLayers.Layers.Text with variable filename as input

Christopher Schmidt crschmidt at metacarta.com
Mon May 19 19:33:41 EDT 2008


On Mon, May 19, 2008 at 07:25:27AM -0400, Carl Morgan wrote:
> Hello,
> 
> I am very new to OpenLayers and just as new to javascript, so I 
> apologize in advance for my lack of basic understanding of all of this.
> 
> But, I am attempting to plot points on a map using 
> OpenLayers.Layers.Text and it works just fine. However I would ideally 
> like to pass the filename in through the URL. In the following line, I 
> would like to replace "./lsrtext.txt" with a variable but am having no 
> luck.
> 
> var newl = new OpenLayers.Layer.Text( "text", {location: "./lsrtext.txt"} );
> 
> Is it possible to do such a thing? I have the code working which 
> processes the variable name, and I am able to process the lat, lon and 
> zoom level this way. But I can't seem to get it working with the 
> filename. The documentation states that the URL of the text file can't 
> be changed once passed in. Does this count as changing?

Thre should be no problems with this. 
{ location: OpenLayers.Util.getParameters()['location']}

Would probably work, for example.

Are you trying to pass in an "http://foo" path where 'foo' is different
from your current domain? that would run afoul of Javascript
Cross-Domain XMLHttpRequest limitations...  

Regards,
-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list