I'm trying to load a simple GML file with OpenLayers, but it doesn't load.

Pretty sure it's a simple issue, but I can't figure out what's wrong.

var meu = new OpenLayers.Layer.Vector("States", {
    protocol: new OpenLayers.Protocol.HTTP({
    url: "teste.GML",
    format: new OpenLayers.Format.GML()
    strategies: [new OpenLayers.Strategy.Fixed()],


Tried Firefox and Safari in Mac OS and Firefox in Linux

1 Answer 1


If you mean that you want to load a file that is stored in the file system of your computer, the short answer is that you cannot. From the Wikipedia:

JavaScript and the DOM provide the potential for malicious authors to deliver scripts to run on a client computer via the web. Browser authors contain this risk using two restrictions. First, scripts run in a sandbox in which they can only perform web-related actions, not general-purpose programming tasks like creating files. Second, scripts are constrained by the same origin policy: scripts from one web site do not have access to information such as usernames, passwords, or cookies sent to another site. Most JavaScript-related security bugs are breaches of either the same origin policy or the sandbox. (http://goo.gl/iqW7n)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.