Register  |  Login
ThinkGeo - GPS Tracking and Mapping Solutions  |  Home  |  Cygnus Track  |   Code Community

Discussion Forums

The online community for users of Map Suite GIS components

User Defined Marker on Map
Last Post 09-24-2009 05:26 AM by Howard. 1 Replies.
Printer Friendly
Sort:
NextNext
You are not authorized to post a reply.
Author Messages Not Resolved
komalUser is Offline
Level 1
Level 1
Posts:1

--
09-22-2009 10:03 AM

Hi Ben,

I referrred many codes on forum which you have provided. These were very helpful for me. But I want to create a marker on map when i click on map. I got the same code using google Api. Could u please help me.

Thanks in advance.

 

Warm Regadrs:

Komal Ahirwal

HowardUser is Offline
MVP
MVP
Posts:942
Avatar

--
09-24-2009 05:26 AM

Komal,

We have an online sample to add a marker on the server side which you can access at http://websamples.thinkgeo.com/webeditionsamples/; please have a try.

Here is the code to add markers on the client side. Hope it helps.

var OnMapCreated = function(map) {

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

    map.events.register("click", map, function(evt) {
    var pixelxy = new OpenLayers.Pixel(evt.x, evt.y);
    var lonlat = map.getLonLatFromPixel(pixelxy);

    var size = new OpenLayers.Size(20, 20);
    var offset = new OpenLayers.Pixel(-(size.w / 2), -size.h);
    var icon = new OpenLayers.Icon('/theme/default/img/marker.gif', size, offset);

    var markers = map.getLayersByName('Markers')[0];
    markers.addMarker(new OpenLayers.Marker(lonlat, icon));
    }
    );
}
If you have any more questions, please feel free to let me know.

Thanks,
Howard
 

You are not authorized to post a reply.

Active Forums 4.1