Polyline Code-Behind Sample

A sample about ASP.NET Google Map Control adding polyline from code-behind.

This is a demo how to add a polylines to Google Map Control in the code behind.

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.

Source

Markup

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

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <div class="jumbotron">
        <h2>Polyline Code-Behind Sample</h2>
        <p>
            A sample about ASP.NET Google Map Control adding polyline from code-behind.
        </p>
    </div>
    <p>
        This is a demo how to add a polylines to Google Map Control in the code behind.
    </p>

    <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>
    </div>

    <script type='text/javascript'>
        function handleClick(sender, e) {
            if (console) console.dir(e);
        }
    </script>
    
</asp:Content>

Code Behind

using System;
using System.Collections.Generic;
using GoogleMaps.Polylines;

namespace GoogleMaps.Samples.samples.Polylines.CodeBehind
{
    public partial class Default : System.Web.UI.Page
    {
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            GoogleMap1.Polylines.Add(new GooglePolyline
            {
                Clickable = true,
                Draggable = true,
                Editable = true,
                OnClientClick = "handleClick",
                StrokeWeight = 10,
                Path = new List
                {
                    new LatLng(42.14304, 24.74967),
                    new LatLng(42.69649, 23.32601)
                }
            });
        }
    }
}