Search code examples
jqueryjvectormap

Adding a custom button in Jvectormap


Is there any way to add a custom button on the top left corner of a normal Jvectormap? (similar to the back button in a drill-down map).

enter image description here


Solution

  • Create a div as a child of the map, so you can position it relative to the map container:

    $("#map").append('<div id="map-action">Action</div>').click(function () {
      //do your action here
    });
    

    Style it like you want, important here is to set the z-order, so it lies above the map:

    CSS:

    #map-action {
      position: absolute;
      left: 10px;
      top: 10px;
      border-radius: 3px;
      z-index: 1000;
      background: #292929;
      color: #ffffff;
      cursor: pointer;
      text-align: center;
      line-height: 10px;
      padding: 6px;
      box-sizing: content-box;
    }