Click or drag to resize

IMapMouseHandlerHitTest Method

Verizon Connect Logo
Print this page
Learn more about Verizon Connect GeoBase.
Get information about the latest release
Test if the given x,y coordinates lie within the bounds of this item.

Namespace:  Telogis.GeoBase
Assembly:  geobase.net (in geobase.net.dll) Version: 4.99.0.0
Syntax
IMapMouseHandler HitTest(
	int x,
	int y,
	IMap aMap
)

Parameters

x
Type: SystemInt32
x coordinate (pixels)
y
Type: SystemInt32
y coordinate (pixels)
aMap
Type: Telogis.GeoBaseIMap
The IMap upon which the click occurred.

Return Value

Type: IMapMouseHandler
The item (if the click occurred on the item). Otherwise null
Remarks
This method is used to determine whether an object lies underneath the co-ordinates at which the mouse was clicked. Objects that render themselves over the IMap (see IMapRenderer) and react to mouse input should use HitTest to check if they have been clicked on.

Related articles: Renderers Tutorial, Mouse Events.

Examples
The following example is taken from BalloonPushPin:
C#
public IMapMouseHandler HitTest(int x, int y, IMap aMap) {

    int x1, y1;

    // Convert 'location' - A BalloonPushPin knows its LatLon - to
    // x & y map co-ordinates.
    aMap.LatLontoXY(out x1, out y1 , location);

    // Get a Rectangle with the size of this BalloonPushPin, located at x1,y1 co-ordinates. 
    System.Drawing.Rectangle rect = Telogis.GeoBase.ImageUtils.IconCache.Rectangle(Icon, x1, y1);

    // If the rectangle contains the co-ordinates that are being tested
    // we have a hit, and so we return this BalloonPushPin.
    if (rect.Contains(x, y)) {
        return this;
    }

    // Otherwise there is no hit, and we return null.
    return null;
}
See Also