VectorSDK Map Method
by mapmyindia_map
HTML
<script src="https://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<script src="https://apis.mapmyindia.com/advancedmaps/v1/<Token or Key>/map_sdk?layer=vector"></script>
<div id="main">
<section id="left-menu">
<center><h4>Map Method</h4></center>
<!-- Map Methods -->
<div id="flip1">
<div id="panel1">
<table width="100%">
<tr>
<td><span class="texlable">getcenter()</span></td>
<td>
<div id="ch1" style="width:100%; height:40px; display: inline-block;">
<label class="switch">
<input id="checkbox1" type="checkbox" Unchecked >
<span class="slider round"></span>
</label>
</div>
</td>
</tr>
<tr>
<td> <span class="texlable">getHeading()</span></td>
<td>
<div id="ch2" style="width:100%; height:40px; display: inline-block;">
<label class="switch">
<input id="checkbox2" type="checkbox" Unchecked>
<span class="slider round"></span>
</label>
</div>
</td>
</tr>
<tr>
<td><span class="texlable">getDiv()</span></td>
<td>
<div id="ch3" style="width:100%; height:40px; display: inline-block;">
<label class="switch">
<input id="checkbox3" type="checkbox" Unchecked>
<span class="slider round"></span>
</label>
</div>
</td>
</tr>
<tr>
<td><span class="texlable">getZoom()</span></td>
<td>
<div id="ch4" style="width:100%; height:40px; display: inline-block;">
...
CSS
#main{
width: 100%;
height: 100%;
background-color: gray;
}
#left-menu{
width: 230px;
height: 100%;
background-color: #e0e0e0;
float: left;
overflow: auto;
}
#right-menu{
width: calc(100% - 230px);
height: 100vh;
float: left;
position:fixed;
right:0;
}
/* Switch checkbox */
.switch {
position: relative;
display: inline-block;
width: 55px;
height: 28px;
}
.switch input {
opacity: 0;
width: 0;
height: 0;
}
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
-webkit-transition: .4s;
transition: .4s;
}
.slider:before {
position: absolute;
content: "";
height: 20px;
width: 20px;
left: 4px;
bottom: 4px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
}
input:checked+.slider {
background-color: #2196F3;
}
input:focus+.slider {
box-shadow: 0 0 1px #2196F3;
}
input:checked+.slider:before {
-webkit-transform: translateX(26px);
-ms-transform: translateX(26px);
transform: translateX(26px);
}
/* Rounded sliders */
.slider.round {
border-radius: 34px;
}
.slider.round:before {
border-radius: 50%;
}
@media only screen and (max-width: 600px) {
#left-menu {
-webkit-transition: height 0.2s;
transition: height 0.2s;
width: 100%;
height: 30%;
background-color: #e0e0e0;
position: absolute;
bottom: 0%;
z-index: 2;
overflow: auto;
}
#right-menu{
width: 100%;
height: 70%;
position: absolute;
z-index: 1;
}
#l1,#cl1{
display:none;
}
}
#flip1
{
color: #3c3c3c;
font-size: 20px;
background-color: #f3f3f3;
padding: 6px 0px;
margin-bottom: 3px;
margin-left: 6px;
margin-right: 6px;
border-radius: 6px;
}
#panel1{
padding:5px 10px 0px;
display: block;
}
::-webkit-scrollbar {
width: 5px;
display: none;
}
.form-control.b-shadow {
-moz-box-shadow: inset 0 0 5px lightgray;
-webkit-box-shadow: inset 0 0 5px lightgray;
...
JavaScript
var map1;
var center = "28.5507160000001,77.2689280000001";
var center = center.split(",");
var lat = center[0];var lng=center[1];
// PanTo() latlng Value
var panto = document.getElementById('panto').value;
var panto = panto.split(",");
var panlat = panto[0];var panlng=panto[1];
//setHeading Value
var setheading = document.getElementById('setheading').value;
// setCenter() latlng Value
var setcenter = document.getElementById('setcenter').value;
var setcenter = setcenter.split(",");
var setcenterlat = setcenter[0];var setcenterlng=setcenter[1];
// setZoom Value
var setzoom = document.getElementById('setzoom').value;
// setTilt value
var settilt = document.getElementById('settilt').value;
// All Map Methods
// getcenter() Method
document.getElementById('checkbox1').addEventListener('change', (event) => {
if (event.target.checked) {
document.getElementById('mapmyindia_result').style.display='block';
document.getElementById("mapmyindia_result").innerHTML = map1.getCenter();
setTimeout(function(){ document.getElementById("checkbox1").checked = false; }, 2000);
}
else {
document.getElementById('mapmyindia_result').style.display='none';
}
});
// getHeading() Method
document.getElementById('checkbox2').addEventListener('change', (event) => {
if (event.target.checked) {
document.getElementById('mapmyindia_result').style.display='block';
document.getElementById("mapmyindia_result").innerHTML = map1.getHeading();
setTimeout(function(){ document.getElementById("checkbox2").checked = false; }, 2000);
}
else {
document.getElementById('mapmyindia_result').style.display='none';
}
});
// getDiv() Method
document.getElementById('checkbox3').addEventListener('change', (event) => {
if (event.target.checked) {
document.getElementById('mapmyindia_result').style.display='block';
document.getElementById("mapmyindia_result").innerHTML = "Look at console";
console.log(map1.getDiv());
setTimeout(function(){ ...