Hi

I have a couple of issues:

I am trying to add my own marker to a map, but it does not seem to work. Also when I try to refer the OpenLayer.js file locally the default red marker disappears.

I have found some examples on the net, but they have been unsuccessful I am afraid. So I thought to ask for some help here.

Now my code looks like this:

<div id="Map" style="height: 250px; width: 400px" ></div>
<script src="http://www.openlayers.org/api/OpenLayers.js"></script>
<!--<script src="js/osm/api/OpenLayers.js"></script>-->
<script>
    var lat = 55.676098;
    var lon = 12.568337;
    var zoom = 11;

    var fromProjection = new OpenLayers.Projection("EPSG:4326");   // Transform from WGS 1984
    var toProjection = new OpenLayers.Projection("EPSG:900913"); // to Spherical Mercator Projection
    var position = new OpenLayers.LonLat(lon, lat).transform(fromProjection, toProjection);

    map = new OpenLayers.Map("Map");
    var mapnik = new OpenLayers.Layer.OSM();
    map.addLayer(mapnik);

    var markers = new OpenLayers.Layer.Markers("Markers");//("Images/Icons/map-marker.png");
    map.addLayer(markers);
    markers.addMarker(new OpenLayers.Marker(position));

    map.setCenter(position, zoom);
</script>

and as you can see I have tried to refer to my own marker from 'Images/Icons/map-marker.png' without any luck.

Also you can see that I have tried to use a local copy of the 'OpenLayers.js', I don't know whether I should have it locally or always refer to 'www.openlayers.org', I believe referring local is good enough?

Also as I wrote earlier, if I refer the local .js file, the red marker, the zoom buttons and the OSM link disappears.

Can anyone help me out?

I have tried to follow the guidelines below, but unsuccesful. http://wiki.openstreetmap.org/wiki/Marker_API

asked 24 May '13, 14:11

zorroguy's gravatar image

zorroguy
11112
accept rate: 0%

closed 24 May '13, 14:29

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
73.9k866671145

1

Yes, but seen aside from the openlayers part. Can I get some help here with setting custom marks on my openstreetmap, without openlayers? I am rather new in this, and I would like to learn and master OSM.

(24 May '13, 15:05) zorroguy

The question has been closed for the following reason "Question is off-topic or not relevant" by Frederik Ramm 24 May '13, 14:29


Your problem is an OpenLayers problem, not an OpenStreetMap problem. Check the documentation/mailing lists linked on www.openlayers.org for OpenLayers help.

The documentation you mention at the end of your post is not related to OpenLayers, it uses a different library named KHtml and is therefore not relevant to your problem.

permanent link

answered 24 May '13, 14:29

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
73.9k866671145
accept rate: 24%

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:

×592
×82
×36

question asked: 24 May '13, 14:11

question was seen: 4,969 times

last updated: 24 May '13, 15:05

powered by OSQA