var map1;
var Marker1;
var center = "28.5507160000001,77.2689280000001";
var center = center.split(",");
var lat = center[0];var lng=center[1];
// Single Marker
document.getElementById('checkbox').addEventListener('change', (event) => {
if (event.target.checked) {
// single marker function call
single_marker();
}
else{
map1.setZoom(4);
MapmyIndia.remove({map:map1,layer:Marker1});
map1.setCenter({lat: lat, lng: lng});
}
});
// Map Function
function initMap1() {
var center = {lat: lat, lng: lng};
map1 = new MapmyIndia.Map(document.getElementById('right-menu'),
{
center: center,
zoomControl: true,
location: true,
});
}
// single marker function
function single_marker(){
var popupOptions= document.getElementById('popupOptions').value;
var draggable= document.getElementById('draggable').value;
var icon = document.getElementById('icon').value;
var width = document.getElementById('width').value;
var height = document.getElementById('height').value;
var popupHtml= document.getElementById('popupHtml').value;
var id= document.getElementById('id').value;
var class1= document.getElementById('class').value;
var position = document.getElementById('position').value;
var marker_html= document.getElementById('marker_html').value;
var fitbounds= document.getElementById('fitbounds').value;
// Single Marker
Marker1 = new MapmyIndia.Marker({
map:map1,
id:id,
class:class1,
position:eval(position),
fitbounds:fitbounds,
fitboundOptions:{padding: 120,duration:1000}, /*if fitbound true*/
icon:icon,
offset:[0,10],
width:width,
height:height,
html:marker_html,
popupOptions:JSON.parse(popupOptions),
popupHtml:popupHtml,
draggable:JSON.parse(draggable)
});
}
initMap1();
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.