Click here to Skip to main content
14,271,889 members
Rate this:
Please Sign up or sign in to vote.
<html>
<body>
<div id="mapdiv"></div>
  <script src="http://www.openlayers.org/api/OpenLayers.js"></script>
  <script>
        map = new OpenLayers.Map("mapdiv");
        map.addLayer(new OpenLayers.Layer.OSM());

        var lonLat = new OpenLayers.LonLat( 72.91152, 19.11186 )
          .transform(
	    // transform from WGS 1984
            new OpenLayers.Projection("EPSG:4326"), 
            // to Spherical Mercator Projection
            map.getProjectionObject() 
          );

        var zoom=16;
        var osm = new OpenLayers.Layer.OSM();
        var vectors = new OpenLayers.Layer.Vector("Vector Layer");
        map.addLayers([osm, vectors]);

        var markers = new OpenLayers.Layer.Markers( "Markers" );
        map.addLayer(markers);

        var size = new OpenLayers.Size(25,37);
        var offset = new OpenLayers.Pixel(-(size.w/2), -size.h);
        
	mymarker = new OpenLayers.Icon('', offset);
        
	markers.addMarker(new OpenLayers.Marker(lonLat, mymarker));

        var point = new OpenLayers.Geometry.Point(lonLat.lon,lonLat.lat);
        vectors.addFeatures([new OpenLayers.Feature.Vector(point)]);
	
	//code for movable icon on map
	vectors.addFeatures([new OpenLayers.Feature.Vector(point, null, {
        externalGraphic: 'marker-icon.png',
	backgroundGraphic: 'marker-shadow.png',
	backgroundXOffset: -32,
	backgroundYOffset: -12,
        graphicWidth: 25,
	graphicHeight: 37,
        graphicXOffset: -37,
        graphicYOffset: -12.5
	})]);
	
    drag = new OpenLayers.Control.DragFeature(vectors, {autoActivate: true});
	
    map.addControl(drag);
    map.setCenter (lonLat, zoom);
   </script>
</body>
</html>


What I have tried:

In the given code I have added the draggable icon(Marker) of location named as "marker-icon.png" with shadow image "marker-shadow.png".

but now I want a 100 meter round circle around the marked location in light blue color. I am not able to do it please help someone.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100