/**
* Custom marker and popup
*/
// config map
let config = {
minZoom: 7,
maxZomm: 18,
};
// magnification with which the map will start
const zoom = 18;
// co-ordinates
const lat = 50.0619474;
const lon = 19.9368564;
// calling map
const map = L.map('map', config).setView([lat, lon], zoom);
// Used to load and display tile layers on the map
// Most tile servers require attribution, which you can set under `Layer`
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
const funny = L.icon({
iconUrl: 'http://grzegorztomicki.pl/serwisy/pin.png',
iconSize: [50, 58], // size of the icon
iconAnchor: [20, 58], // changed marker icon position
popupAnchor: [0, -60] // changed popup position
});
// create popup contents
const customPopup = '<input type="text">';
// specify popup options
const customOptions = {
'maxWidth': 'auto', // set max-width
'className': 'customPopup' // name custom popup
}
// create marker object, pass custom icon as option, pass content and options to popup, add to map
L.marker([lat, lon], {
icon: funny
})
.bindPopup(customPopup, customOptions)
.addTo(map);
* {
margin: 0;
padding: 0
}
html {
height: 100%
}
body,
html,
#map {
height: 100%;
margin: 0;
padding: 0
}
body {
height: 100%;
}
.customPopup .leaflet-popup-content-wrapper,
.customPopup .leaflet-popup-tip {
background: #000;
color: #fff;
}
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.6.0/dist/leaflet.css" />
<script src="https://unpkg.com/leaflet@1.6.0/dist/leaflet.js"></script>
<div id="map"></div>