Googlemap control for Asp.Net MVC

Marker Client Events

Marker Settings

About this example

This example shows the client-side events asociated to the google map marker supported by Googlemap control for Asp.Net MVC.

Interact with the marker above to see the results

The Marker Object on Googlemap control for Asp.Net MVC has an Id property which is passed to the client side event handler through the arguments. That property could be binded to some datasource object using the databinding capabilities and also could be used to keep the track of the user interaction with the markers and send it back to the server to make some decitions.


    @(Html.GoogleMap()
        .Name("map")
        .Height(420)
        .Markers(m =>
        {
            m.Add().Id("UniqueId-1")
                .Title("Hello World!")
                .Longitude(-82)
                .Latitude(23);
        })
        .MarkerEvents(events => events.OnMarkerClick("markerClick"))
    )
    <script type="text/javascript">
        function markerClick(args) {       
            if (args.eventName === 'click') {
                alert("You clicked the marker with id =" + args.id);
            }
        }
    </script>