Polyline Server Events Sample

A sample about ASP.NET Google Map Control polyline server events usage.

GoogleMap control polyline server event handling sample.
The polyline 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) by the server side code.

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/Polylines/Polylines.master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="GoogleMaps.Samples.samples.Polylines.ServerEvents.Default" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <div class="jumbotron">
        <h2>Polyline Server Events Sample</h2>
        <p>
            A sample about ASP.NET Google Map Control polyline server events usage.
        </p>
    </div>
    <p>
        GoogleMap control polyline server event handling sample.
        <br />
        The polyline 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) by the server side code.
    </p>

    <%--<asp:RadioButtonList ID="SelectedEvent" runat="server" RepeatLayout="Table">
        <asp:ListItem Text="Click" />
        <asp:ListItem Text="DoubleClick" />
        <asp:ListItem Text="MouseDown" />
        <asp:ListItem Text="MouseOut" />
        <asp:ListItem Text="MouseOver" />
        <asp:ListItem Text="MouseUp" />
        <asp:ListItem Text="RightClick" />
    </asp:RadioButtonList>--%>

    <div class="map-wrap">
        <map:GoogleMap ID="GoogleMap1" runat="server" Width="100%" Height="600px" Latitude="42.1229" Longitude="24.7879" Zoom="7" CssClass="map" FullscreenControl="true">
        </map:GoogleMap>
        <map:GooglePolyline ID="GooglePolyline1" TargetControlID="GoogleMap1" runat="server"
            StrokeWeight="10" Clickable="true" Draggable="true" Editable="true"
            OnClick="HandleClick" OnDragEnd="HandleDrag" >
            <map:LatLng Latitude="42.14304" Longitude="24.74967" />
            <map:LatLng Latitude="42.69649" Longitude="23.32601" />
        </map:GooglePolyline>
    </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.Polylines.ServerEvents
{
    public partial class Default : System.Web.UI.Page
    {
        /// 
        /// Handles the clear botton click event.
        /// 
        /// The sender - button itself
        /// The  instance containing the event data.
        protected void HandleClearClick(object sender, EventArgs e)
        {
            lbEvents.Items.Clear();
        }

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

        /// 
        /// Handles the double click polyline event.
        /// 
        /// The sender - polyline itself
        /// The  instance containing the event data.
        protected void HandleDoubleClick(object sender, MouseEventArgs e)
        {
            PrintEvent("DoubleClick", e);
        }

        /// 
        /// Handles the drag polyline event.
        /// 
        /// The sender - polyline itself
        /// 
        protected void HandleDrag(object sender, MouseEventArgs e)
        {
            PrintEvent("Drag", e);
        }

        /// 
        /// Handles the mouse down polyline event.
        /// 
        /// The sender - polyline itself
        /// The  instance containing the event data.
        protected void HandleMouseDown(object sender, MouseEventArgs e)
        {
            PrintEvent("MouseDown", e);
        }

        // Too often 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 polyline event.
        /// 
        /// The sender - polyline itself
        /// The  instance containing the event data.
        protected void HandleMouseOut(object sender, MouseEventArgs e)
        {
            PrintEvent("MouseOut", e);
        }

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

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

        /// 
        /// Handles the right click polyline event.
        /// 
        /// The sender - polyline itself
        /// The  instance containing the event data.
        protected void HandleRightClick(object sender, MouseEventArgs e)
        {
            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));
        }
    }
}