# Custom Icons
Custom Marker Icons
![](https://c.tile.openstreetmap.org/13/4068/2867.png)
![](https://b.tile.openstreetmap.org/13/4068/2866.png)
![](https://b.tile.openstreetmap.org/13/4067/2867.png)
![](https://a.tile.openstreetmap.org/13/4069/2867.png)
![](https://a.tile.openstreetmap.org/13/4068/2868.png)
![](https://a.tile.openstreetmap.org/13/4067/2866.png)
![](https://c.tile.openstreetmap.org/13/4069/2866.png)
![](https://c.tile.openstreetmap.org/13/4067/2868.png)
![](https://b.tile.openstreetmap.org/13/4069/2868.png)
![](https://a.tile.openstreetmap.org/13/4066/2867.png)
![](https://b.tile.openstreetmap.org/13/4070/2867.png)
![](https://c.tile.openstreetmap.org/13/4066/2866.png)
![](https://a.tile.openstreetmap.org/13/4070/2866.png)
![](https://b.tile.openstreetmap.org/13/4066/2868.png)
![](https://c.tile.openstreetmap.org/13/4070/2868.png)
![](static/images/baseball-marker.png)
![](/images/baseball-marker.png)
Leaflet | © OpenStreetMap contributors
show code
<template> <div> <div style="height: 20%; overflow: auto;"> <h3>Custom Marker Icons</h3> <label for="iconSize">Icon size:</label> <input id="iconSize" v-model="iconSize" type="range" min="1" max="200" value="64" > <label for="customTextInput">Custom text: </label> <input id="customTextInput" v-model="customText" type="text" > </div> <l-map :zoom="zoom" :center="center" style="height: 500px; width: 100%" > <l-tile-layer :url="url" :attribution="attribution" /> <!-- Use default icon --> <l-marker :lat-lng="[47.41322, -1.219482]" /> <!-- Use icon given in icon property --> <l-marker :lat-lng="[47.41322, -1.209482]" :icon="icon" /> <!-- Create image icon (icon) from l-icon tag --> <l-marker :lat-lng="[47.41322, -1.199482]"> <l-icon :icon-size="dynamicSize" :icon-anchor="dynamicAnchor" icon-url="/images/baseball-marker.png" /> </l-marker> <!-- Create HTML icon (divIcon) by providing content inside the l-icon tag --> <l-marker :lat-lng="[47.41322, -1.189482]"> <l-icon :icon-anchor="staticAnchor" class-name="someExtraClass" > <div class="headline"> {{ customText }} </div> <img src="/images/layers.png"> </l-icon> </l-marker> </l-map> </div> </template> <script> import { LMap, LTileLayer, LMarker, LIcon } from "vue2-leaflet"; import { latLng, icon } from "leaflet"; export default { name: "Icon", components: { LMap, LTileLayer, LMarker, LIcon }, data() { return { zoom: 13, center: latLng(47.41322, -1.219482), url: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors', icon: icon({ iconUrl: "static/images/baseball-marker.png", iconSize: [32, 37], iconAnchor: [16, 37] }), staticAnchor: [16, 37], customText: "Foobar", iconSize: 64 }; }, computed: { dynamicSize() { return [this.iconSize, this.iconSize * 1.15]; }, dynamicAnchor() { return [this.iconSize / 2, this.iconSize * 1.15]; } }, methods: {} }; </script> <style> .someExtraClass { background-color: aqua; padding: 10px; border: 1px solid #333; border-radius: 0 20px 20px 20px; box-shadow: 5px 3px 10px rgba(0, 0, 0, 0.2); text-align: center; width: auto !important; height: auto !important; margin: 0 !important; } </style>
Copied!