Why not ask your question on the new OpenStreetMap Community Forum?


i got a problem about the example in the web pag of that link.

  var layer = new OpenLayers.Layer.Vector("Polygon", {
                strategies: [new OpenLayers.Strategy.Fixed()],
                protocol: new OpenLayers.Protocol.HTTP({
                    url: "myosmfile.osm",   //<-- relative or absolute URL to your .osm file
                    format: new OpenLayers.Format.OSM()
                projection: new OpenLayers.Projection("EPSG:4326")

this part of code seems does not work, i have put the html file alongside the osm file in an apache server, but the result did not change, it did not show the area which is included in the osm file.

I did not how this happened,i need your help.

asked 24 Mar '11, 06:33

monument's gravatar image

accept rate: 0%

edited 25 Mar '11, 11:50

TomH's gravatar image

TomH ♦♦

Note: This is not strictly OpenStreetMap related but rather a Openlayers question and therefore offtopic here.

Looking at the example in the wiki the display is always centered at latitude 51.950, longitude 7.613 rather then the center of the osm file you provide. You can either hardcode the "correct" center or center "dynamically" using the getDataExtent property of the vector layer. For further documentation please read the documentaion on vector layers and setCenter.

permanent link

answered 24 Mar '11, 07:57

petschge's gravatar image

accept rate: 21%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 24 Mar '11, 06:33

question was seen: 5,768 times

last updated: 25 Mar '11, 11:50

powered by OSQA