How to Create a Clickable Map Using Your Own Custom Map Image

you can find co-ordinate of a specific location inside your image map by the help of ms-paint and then put into polygon or circle point.

<div style="float:left;width:960px;">
        <div style="float: left; width: 960px;">
            <img src="~/Images/CampingMap.png" style="width: 930px;" id="CampingMapImg" />
            <svg width="930px" height="800px" style="overflow: hidden; position: absolute; top: 0; left: 8px;">
                <polygon fill="#000000" fill-opacity="0.5" stroke="#000000" stroke-width="2" points="878,125 896,125 896,148 878,148" stroke-opacity="1" stroke-linejoin="round" data-campid="818" data-available="false" onclick="CampStatus(this);"></polygon>
                <polygon class="poly_avail" fill="rgba(188, 112, 112, 0.55)" fill-opacity="0.5" stroke="#000000" stroke-width="2" points="860,125 877,125 877,148 860,148" stroke-opacity="1" stroke-linejoin="round" data-campid="817" data-available="true" onclick="CampStatus(this);"></polygon>
                <polygon class="poly_avail" fill="rgba(188, 112, 112, 0.55)" fill-opacity="0.5" stroke="#000000" stroke-width="2" points="842,125 859,125 859,148 842,148" stroke-opacity="1" stroke-linejoin="round" data-campid="816" data-available="true" onclick="CampStatus(this);"></polygon>
                <polygon class="poly_avail" fill="rgba(188, 112, 112, 0.55)" fill-opacity="0.5" stroke="#000000" stroke-width="2" points="71,338 106,338 106,364 87,364 77,352" stroke-opacity="1" stroke-linejoin="round" data-campid="18" data-available="true" onclick="CampStatus(this);"></polygon>
                <circle class="poly_avail" cx="649" cy="67" r="16" stroke="black" stroke-width="3" fill="rgba(188, 112, 112, 0.55)" data-campid="902G" data-available="true" onclick="CampStatus(this);" />
                <circle class="poly_avail" cx="605" cy="87" r="16" stroke="black" stroke-width="3" fill="000000" data-campid="901G" data-available="false" onclick="CampStatus(this);" fill-opacity="0.5" />
            </svg>
            <script type="text/javascript">
                $(window).load(function () {
                    debugger;
                    $('svg').css("top", $('#CampingMapImg').position().top + "px").css("left", $('#CampingMapImg').position().left + "px");
                });
                $(document).ready(function () {
                    $('.poly_avail').hover(function () {
                        $(this).attr("fill", "rgba(70, 136, 231, 0.55)");
                    }, function () {
                        $(this).attr("fill", "rgba(188, 112, 112, 0.55)");
                    });
                });
                function CampStatus(current) {
                    var currentSelected = $(current);
                    //if (currentSelected.attr("data-available") == "true") {
                    //    alert("This is Camp No: " + currentSelected.attr("data-CampID") + " and this area is available.");
                    //}
                    //else if (currentSelected.attr("data-available") == "false") {
                    //    alert("This is Camp No: " + currentSelected.attr("data-CampID") + " and this area is not available.");
                    //}
                   
                }
            </script>
        </div>
    </div>

Comments

Popular posts from this blog

How to create RSS Feed in Asp.Net

Auto generate change scripts in SQL Server Management Studio SSMS for tables

HOW TO Use the NumericUpDown Control