NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

http://wiki.openstreetmap.org/wiki/OpenLayers_osm_file_example

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

monument
69567
accept rate: 0%

edited 25 Mar '11, 11:50

TomH's gravatar image

TomH ♦♦
3.3k83943


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

petschge
8.3k217398
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

By RSS:

Answers

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:

×122

question asked: 24 Mar '11, 06:33

question was seen: 5,881 times

last updated: 25 Mar '11, 11:50

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum