Step 1:
- Create a new project in visual studio.
- Add a new web form or existing form.
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div id="map" style="width: 100%; height: 500px;"></div>
</form>
</body>
</html>
Step 2:
Next Add Script for loading the map and maker.
Add the following script in the head section.
<head runat="server">
<title></title>
<script src="https://polyfill.io/v3/polyfill.min.js?features=default"></script>
<script src="https://maps.googleapis.com/maps/api/js?key=Your Key" type="text/javascript"></script>
</head>
Add Map loading js function mentioned below
Next Add Show Marker function inside of body.
Declare the variable mentioned below
Please refer below full js script on map loading and Show marker.
<script type="text/javascript">
var map = null;
var cordinate = { lat: 23.805450, lng: 78.486328 };
function loadMap() {
map = new google.maps.Map(document.getElementById("Map"),
{
center: new google.maps.LatLng(23.805450, 78.486328),
zoom: 4,
mapTypeId: google.maps.MapTypeId.ROADMAP,
panControl: true,
zoomControl: true,
zoomControlOptions: {
style: google.maps.ZoomControlStyle.SMALL,
position: google.maps.ControlPosition.LEFT_CENTER
},
streetViewControl: false,
fullscreenControl: false
});
showMarker(cordinate);
}
function showMarker(myLatLng) {
new google.maps.Marker({
position: myLatLng,
map
});
}
</script>
Comments
Post a Comment