NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

Hi,

I need to display a marker on map when i clicked on the map and also i have to fetch the address of that gps point

OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, {
defaultHandlerOptions: { 'single': true, 'double': false, 'pixelTolerance': 0, 'stopSingle': false, 'stopDouble': false },

initialize: function(options) {
    this.handlerOptions = OpenLayers.Util.extend(
    {}, this.defaultHandlerOptions
        );
    OpenLayers.Control.prototype.initialize.apply(
        this, arguments
        ); 
    this.handler = new OpenLayers.Handler.Click(
        this, {
            'click': this.trigger
        }, this.handlerOptions
        );
},

trigger: function(e) {
    var lonlat = map.getLonLatFromPixel(e.xy);
    alert("You clicked near " + lonlat.lat + " N, " +
        + lonlat.lon + " E");
}

}); var map; function showGeoFenceMap(){
map = new OpenLayers.Map('geofencMap');
map.addLayers([new OpenLayers.Layer.OSM()]); map.addControl(new OpenLayers.Control.LayerSwitcher()); map.zoomToMaxExtent();
var click = new OpenLayers.Control.Click(); map.addControl(click); click.activate(); }

I have tried this am not getting some strange values. i want to use default layer.

Thanks, Kiran

asked 21 Jun '13, 11:26

amkiranv's gravatar image

amkiranv
1333
accept rate: 0%

closed 24 Jun '13, 22:13

SimonPoole's gravatar image

SimonPoole ♦
44.7k13326701

The question has been closed for the following reason "Question is off-topic or not relevant" by SimonPoole 24 Jun '13, 22:13


This is a specific OpenLayers question and should be asked on an appropriate OL forum.

permanent link

answered 24 Jun '13, 22:13

SimonPoole's gravatar image

SimonPoole ♦
44.7k13326701
accept rate: 18%

edited 25 Jun '13, 12:51

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:

×122

question asked: 21 Jun '13, 11:26

question was seen: 3,406 times

last updated: 25 Jun '13, 12:51

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum