<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-15">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hello.<br>
<br>
I am using openlayers with osm.<br>
<br>
I want to add new POIs to my map by using.<br>
<br>
<blockquote type="cite"><small><small> var feature
= new OpenLayers.Feature.Vector(<br>
new
OpenLayers.Geometry.Point(1.234,1.234).transform(epsg4326,
projectTo),<br>
{description:'desc'} ,<br>
{externalGraphic: 'image.png',
graphicHeight: 10, graphicWidth: 10, graphicXOffset:-5,
graphicYOffset:-5 }<br>
); <br>
vectorLayer.addFeatures(feature);</small></small></blockquote>
<br>
Problem is, I want to do this in code before the map is being
initialized (in my code by)<br>
<br>
<blockquote type="cite"><small><small><div style="width:100%;
height:100%;" id="mapdiv"><br>
</div> <br>
<script
src=<a class="moz-txt-link-rfc2396E" href="http://www.openlayers.org/api/OpenLayers.js">"http://www.openlayers.org/api/OpenLayers.js"</a>></script>
<br>
<script><br>
OpenLayers.Lang.setCode('de');<br>
//map = new OpenLayers.Map("mapdiv", { controls: [] });<br>
map = new OpenLayers.Map("mapdiv", {controls: [new<br>
OpenLayers.Control.Attribution()]});<br>
<br>
map.addLayer(new OpenLayers.Layer.OSM());<br>
projectTo = map.getProjectionObject();<br>
epsg4326 = new OpenLayers.Projection("EPSG:4326")<br>
var lonLat = new OpenLayers.LonLat( 6.959911 , 50.940664
).transform(epsg4326, projectTo);<br>
var zoom = 14 ;<br>
map.setCenter(lonLat, zoom);<br>
var vectorLayer = new OpenLayers.Layer.Vector("Overlay");<br>
var feature = new OpenLayers.Feature.Vector(<br>
new OpenLayers.Geometry.Point( 6.959911 , 50.940664
).transform(epsg4326, projectTo),<br>
{<br>
description: 'Standort'<br>
},<br>
{<br>
externalGraphic: 'schild.png',<br>
graphicHeight: 74 , graphicWidth: 53 , graphicXOffset:
-26.5 , graphicYOffset: -74<br>
});<br>
<br>
vectorLayer.addFeatures(feature);<br>
map.addLayer(vectorLayer);<br>
//Add a selector control to the vectorLayer with popup
functions<br>
<br>
var controls = {<br>
selector: new
OpenLayers.Control.SelectFeature(vectorLayer,<br>
{<br>
onSelect: createPopup,<br>
onUnselect: destroyPopup<br>
})<br>
};<br>
<br>
function createPopup(feature)<br>
{<br>
feature.popup = new OpenLayers.Popup.FramedCloud("pop",<br>
feature.geometry.getBounds().getCenterLonLat(),<br>
null, '<div class="markerContent">' +
feature.attributes.description + '</div>',<br>
null,<br>
true,<br>
<br>
function ()<br>
{<br>
controls['selector'].unselectAll();<br>
});<br>
//feature.popup.closeOnMove = true;<br>
map.addPopup(feature.popup);<br>
}<br>
<br>
function destroyPopup(feature)<br>
{<br>
feature.popup.destroy();<br>
feature.popup = null;<br>
}<br>
map.addControl(controls['selector']);<br>
controls['selector'].activate(); <br>
controls =
map.getControlsByClass('OpenLayers.Control.Navigation');<br>
<br>
for(var I = 0; i < controls.length; ++i)<br>
controls.disableZoomWheel();<br>
</script></small></small><br>
</blockquote>
<br>
If I put the javascript on top of the page and let the map div come
after, it does not show.<br>
<br>
So basically I want to add new points somewhere in code before the
map div. How do I need to structure the javascript-parts to do that?<br>
<br>
Best and thanks for your efforts.<br>
</body>
</html>