Polygon Server Events Sample

A sample about ASP.NET Google Map Control overlay server events.

The polygon fires next events: click, double click, mouse down, mouse move, mouse out, mouse over, mouse up, right click.
The event fired by the polyline will be listed in the info list bellow (most recent first).

Thank you for using the Development Build of ASP.NET Google Map Control to build Google Maps faster.
Purchase the Commercial Build now to get access to all product updates and the ASP.NET Google Map Control expert support.
Events (most recent first):

Source

Markup

<%@ Page Language="C#" MasterPageFile="~/samples/Overlays/Overlays.master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="GoogleMaps.Samples.samples.Overlays.ServerEvents.Default" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <div class="jumbotron">
        <h2>Polygon Server Events Sample</h2>
        <p>
            A sample about ASP.NET Google Map Control overlay server events.
        </p>
    </div>
    <p>
        The polygon fires next events: click, double click, mouse down, mouse move, mouse
        out, mouse over, mouse up, right click.<br />
        The event fired by the polyline will be listed in the info list bellow (most recent
        first).
    </p>
    <div class="map-wrap">
        <map:GoogleMap ID="GoogleMap1" runat="server" Width="100%" Height="600px" Latitude="42.1229"
            Longitude="24.7879" Zoom="6" CssClass="map" FullscreenControl="true">
        </map:GoogleMap>
        <map:GooglePolygon TargetControlID="GoogleMap1" runat="server" OnClick="HandleClick" Draggable="true" Editable="true">
            <%--
                TODO: Add some of those bellow to test them:
                OnDoubleClick="HandleDoubleClick"
                OnMouseDown="HandleMouseDown" 
                OnMouseOut="HandleMouseOut" 
                OnMouseOver="HandleMouseOver"
                OnMouseUp="HandleMouseUp" 
                OnRightClick="HandleRightClick"
            --%>
            <map:LatLng Latitude="37.97918" Longitude="23.716647" />
            <map:LatLng Latitude="41.036501" Longitude="28.984895" />
            <map:LatLng Latitude="44.447924" Longitude="26.097879" />
            <map:LatLng Latitude="44.802416" Longitude="20.465601" />
            <map:LatLng Latitude="42.002411" Longitude="21.436097" />
            <map:LatLng Latitude="37.97918" Longitude="23.716647" />
        </map:GooglePolygon>
    </div>
    <div>
        Events (most recent first):
        <asp:Button runat="server" Text="Clear" OnClick="HandleClearClick" />
    </div>
    <asp:ListBox ID="lbEvents" runat="server" Rows="20" Width="100%"></asp:ListBox>
    
</asp:Content>

Code Behind

using System;

namespace GoogleMaps.Samples.samples.Overlays.ServerEvents
{
    public partial class Default : System.Web.UI.Page
    {
        /// 
        /// Handles the clear click.
        /// 
        /// The sender.
        /// The  instance containing the event data.
        protected void HandleClearClick(object sender, EventArgs e)
        {
            lbEvents.Items.Clear();
        }

        /// 
        /// Handles the click.
        /// 
        /// The sender.
        /// The  instance containing the event data.
        protected void HandleClick(object sender, MouseEventArgs e)
        {
            this.PrintEvent("Click", e);
        }

        /// 
        /// Handles the double click.
        /// 
        /// The sender.
        /// The  instance containing the event data.
        protected void HandleDoubleClick(object sender, MouseEventArgs e)
        {
            this.PrintEvent("DoubleClick", e);
        }
        /// 
        /// Handles the mouse down.
        /// 
        /// The sender.
        /// The  instance containing the event data.
        protected void HandleMouseDown(object sender, MouseEventArgs e)
        {
            this.PrintEvent("MouseDown", e);
        }

        // Too eften fired, that's why omitted.
        ///// 
        ///// Handles the mouse move.
        ///// 
        ///// The sender.
        ///// The  instance containing the event data.
        //protected void HandleMouseMove(object sender, MouseEventArgs e) {
        //    this.PrintEvent("MouseMove", e);
        //}

        /// 
        /// Handles the mouse out.
        /// 
        /// The sender.
        /// The  instance containing the event data.
        protected void HandleMouseOut(object sender, MouseEventArgs e)
        {
            this.PrintEvent("MouseOut", e);
        }

        /// 
        /// Handles the mouse over.
        /// 
        /// The sender.
        /// The  instance containing the event data.
        protected void HandleMouseOver(object sender, MouseEventArgs e)
        {
            this.PrintEvent("MouseOver", e);
        }

        /// 
        /// Handles the mouse up.
        /// 
        /// The sender.
        /// The  instance containing the event data.
        protected void HandleMouseUp(object sender, MouseEventArgs e)
        {
            this.PrintEvent("MouseUp", e);
        }

        /// 
        /// Handles the right click.
        /// 
        /// The sender.
        /// The  instance containing the event data.
        protected void HandleRightClick(object sender, MouseEventArgs e)
        {
            this.PrintEvent("RightClick", e);
        }

        /// 
        /// Prints the event.
        /// 
        /// The name.
        /// The  instance containing the event data.
        protected void PrintEvent(string name, MouseEventArgs e)
        {
            lbEvents.Items.Add(
                string.Format("{0} event was fired (lat: {1}, lng: {2}).",
                    name, e.Position.Latitude, e.Position.Longitude));
        }
    }
}