Sudhir Koimattur Sudhir Koimattur - 2 years ago 178
jQuery Question

ReferenceError: OpenLayers is not defined in openstreetmap

Hello I'm trying to implement a marker to the

and it is showing the error in firebug as
ReferenceError: OpenLayers is not defined
. Here is the code which I have implemented :

map = new OpenLayers.Map("map", {
projection: "EPSG:900913",
displayProjection: "EPSG:4326"
map.addLayer(new OpenLayers.Layer.OSM());
var markers = new
OpenLayers.Layer.Text("text", {location: "<?php echo $root_url; ?>"+"/marker_a.png", projection: map.displayProjection});
<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src=",12.8607,77.7664,13.0728&layer=mapnik" style="border: 1px solid black"></iframe>
<br />
<a href="">View Larger Map</a>

Thanks in advance.

Answer Source
image = "<?php echo $root_url; ?>" + "/marker_a.png";
var size = new OpenLayers.Size(21,25);
var offset = new OpenLayers.Pixel(-(size.w/2), -size.h);
var icon1 = new OpenLayers.Icon(image, size, offset);
var lonLat1 = new OpenLayers.LonLat(res[2],res[1]).transform( new `OpenLayers.Projection("EPSG:4326"), 
var marker1 = new OpenLayers.Marker(lonLat1, icon1); 
marker1.icon.size = size; 
marker1.icon.offset = offset; 
markers.addMarker(marker1, icon1); 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download