SetOnClickListener

(TMap.OnClickListener Method)

Registers an event handler for mouse-click event. The argument-OnClick is a function which would be called when the map is clicked with the mouse. You should implement the function OnClick. Be sure that OnClick would have two arguments: the first is latitude, the second longitude, which represents where the mouse is clicked on the map, if the map is to display the latitude and longitude values when double clicked.
public OnClickListener(OnClick):Void

Parameters

  • OnClick : Object - It is a function which would be called when the map is clicked with the mouse.You should implement the function OnClick. OnClick would have two arguments:the first is latitude,the second is longitude which represents where the map is clicked on the map.
  • Returns

  • Void
  • Example

    The following example creates a map and changes its size from 640 by 400 pixels to 800 by 600 pixels.
    <div id="mapContainer"  style="width: 640px; height: 400px;"></div>
    <script type="text/javascript">
        var map0 = new TMap(mapContainer, 25.7590256665386, -80.3738769902151, 15, mapLoaded, 1, true, "", "hybrid");
       
        function mapLoaded() {
            map0.SetOnClickListener( MapClicked);
        }
        function MapClicked(lat,lon){
            map0.ShowInfoWindow(lat, lon,"width=240;height=100", "You clicked on:", "Latitude=\t" + lat + "\nLongitude=\t" + lon);
        }
    </script>
        

    See also

  • SetOnDoubleClickListener()

    See example

    Adding map event listener