Working with Google Map & Markers API v.2

<!--HTML -->
<div id="map"></div>
//JavaScript
<script src="https://maps.googleapis.com/maps/api/js?key=your_key"></script>
<script src="~/Areas/Admin/Assets2/markerclusterer.js"></script>

//Draw a google map without any marker on page load 
<script>
    var map;
    var markers = [];
    $(function () {
        var mapOptions = {
            center: { lat: 23.564587, lng: 90.569874 },
            zoom: 7,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        };
            map = new google.maps.Map(document.getElementById("map"), mapOptions);
    });
</script>


//--> Load marker data on search button click event 
<script>
    var $SubmitSearch = $('#SubmitSearch');
      
    //-->document.ready()
    $(function () {
        $SubmitSearch.click(function (e) {
            e.preventDefault();
            var fd = new FormData();

            $.ajax({
                type: 'POST',
                url: "../../../../Admin/Search/SearchResult/",
                processData: false,  // tell jQuery not to process the data
                contentType: false,   // tell jQuery not to set contentType
                data: fd,
                beforeSend: function () {
                    $SubmitSearch.attr('disabled', 'disabled');
                    $SubmitSearch.html('Working…');
                },
                success: function (response) {
                    deleteMarkers();
                    var hasData = response.hasdata;
                    if (hasData) {
                        var sites = JSON.parse(response.data);
                        var serialNo = 0;
                        //-->Looping the parsed data
                        sites.forEach(function (site, index) {
                            serialNo++;

                            var marker = new google.maps.Marker({
                                name: "12345",
                                position: { lat: site.Latitude, lng: site.Longitude },
                                map: map,
                                //icon: "../../Assets/images/google-map-markers/OutletMarker.png",
                                title: site.SiteId.toString()
                            });

                            marker.addListener('click', function () {

                                var contentString = '';

                                //-->Fetch default images from server
                                $.ajax({
                                    type: "POST",
                                    url: '../../../Common/GetMarkerDetails',
                                    contentType: "application/json; charset=utf-8",
                                    data: "{'siteId':'" + site.SiteId + "'}",
                                    dataType: "json",
                                    beforeSend: function () {

                                    },
                                    success: function (result) {
                                        contentString = '<img src="http://localhost:63716/Images/'+ result.ImageName +'" />';
                                    },
                                    error: function (request, status, error) {

                                    }
                                });
                                //<--- Fetch default images from server

                                var infowindow = new google.maps.InfoWindow({
                                    content: contentString
                                });

                                infowindow.open(map, marker);
                            });

                            markers.push(marker);
                        });
                        //<--Looping the parsed data


                        //-->Add marker clustering
                        var markerCluster = new MarkerClusterer(map, markers, {
                            gridSize: 40,
                            minimumClusterSize: 50
                        });
                        //-->Add marker clustering

                    }
                    else {
                        alert('Your search did not match with any record.')
                        $ShowMore.hide(); // No need to show anymore.
                        $('#resultCount').hide();
                    }

                },
                error: function (request, status, error) {
                    alert('Unknown error.');
                    $ShowMore.html('Error in loading data');
                    $ShowMore.attr('disabled', 'disabled');
                },
                complete: function () {
                    // ShowMarketResearchPlanningPopup();
                    $SubmitSearch.removeAttr('disabled');
                    $SubmitSearch.html('Search');
                }
            });

        });
        //<-- Submit Search

        // Sets the map on all markers in the array.
        function setMapOnAll(map) {
            for (var i = 0; i < markers.length; i++) {
                markers[i].setMap(map);
            }
        }

        // Removes the markers from the map, but keeps them in the array.
        function clearMarkers() {
            setMapOnAll(null);
        }

        // Shows any markers currently in the array.
        function showMarkers() {
            setMapOnAll(map);
        }

        // Deletes all markers in the array by removing references to them.
        function deleteMarkers() {
            clearMarkers();
            markers = [];
        }

    });
    //<-- document.ready()
</script>
//<-- Load marker data on search button click event

Base Controller in ASP.NET MVC Application

using LogExpress.ExceptionLogger;
using System;
using System.Globalization;
using System.Web;
using System.Web.Configuration;
using System.Web.Mvc; 
using EnDecryptor;

namespace GPOOH
{
    public abstract class BaseController : Controller
    {
        protected string BaseUrl = "http://localhost:63716/";
        protected string ConnectionString = WebConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString;

        protected string[] InputDateFormatsAllowed = {
                                                       "d/M/yy", "d/M/yyyy",
                                                       "d/MM/yy", "d/MM/yyyy", 
                                                       "dd/M/yy", "dd/M/yyyy", 
                                                       "dd/MM/yy", "dd/MM/yyyy",

                                                       "d-M-yy", "d-M-yyyy",
                                                       "d-MM-yy", "d-MM-yyyy", 
                                                       "dd-M-yy", "dd-M-yyyy", 
                                                       "dd-MM-yy", "dd-MM-yyyy",

                                                       "d.M.yy", "d.M.yyyy",
                                                       "d.MM.yy", "d.MM.yyyy", 
                                                       "dd.M.yy", "dd.M.yyyy", 
                                                       "dd.MM.yy", "dd.MM.yyyy"

                                                    };

        protected CultureInfo myCulture = new CultureInfo("bn-BD-gp");

        /// <summary>
        /// Encryption
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        protected string EnCrypt(string str)
        {
            string enccryptedText = Encryptor.Encrypt(str);
            return enccryptedText;
        }

        /// <summary>
        /// Decryption
        /// </summary>
        /// <param name="encryptedText"></param>
        /// <returns></returns>
        protected string DeCrypt(string encryptedText)
        {
            string deccryptedText = Decryptor.Decrypt(encryptedText);
            return deccryptedText;
        }


        protected void LogException(Exception exception)
        {
            var path = HttpContext.Server.MapPath("~/App_Data");
            ExceptionLog.Create(exception, path);
        }  
    }
}


//Usage

public class SearchController : BaseController
{
    public ActionResult Index()
    {
        try
        {
            using (SqlConnection connection=new SqlConnection(this.ConnectionString))
            {

            }
        }
        catch (Exception Ex)
        {
            this.LogException(Ex);
        }
        
        return View();
    }
}