All Apps and Add-ons

Using tokens to center the map

t183194
Explorer

We have a use case where we want to use a static zoom value i.e. 12 but re-center the map when a new search runs (the search generates new lat/long values which we are tokenizing and then wanting to use these tokens as the map center values i.e.
$addr_lat$
$addr_long$
This works on the inital search but not on any subsequent searches. Have tried unsetting the token values but no luck.
Any help appreciated.

0 Karma

shaskell_splunk
Splunk Employee
Splunk Employee

Using tokens to modify the format menu settings will not work. Can you try the latest version of the app and enable the Auto Fit & Zoom feature in Map settings.

Auto Fit & Zoom Docs

This feature is meant to center the map based on the plotted markers with the maximum possible zoom level. It's a newer feature so let me know if you have any issues.

0 Karma

DalJeanis
Legend

Can you post the code you are using... with any confidential info redacted, please?

0 Karma

t183194
Explorer

Sure..here is some test xml

Test Map

<input type="text" token="lat">
  <label>Latitude</label>
  <default>-45.856</default>
</input>
<input type="text" token="long">
  <label>Longitude</label>
  <default>170.509</default>
</input>


<panel>
  <viz type="leaflet_maps_app.leaflet_maps">
    <title>Test Map</title>
    <search>
      <query>|makeresults 
      |eval latitude=$lat$, longitude=$long$,
      icon="exclamation",
      markerColor="#65A637",
      markerPriority = "1000",
      markerSize = "15,35",
      shadowSize = "20,36",
      shadowAnchor = "15,30", 
      markerAnchor = "5,30",
      markerType="svg",
      description= "Test"
      |table latitude, longitude, description, markerColor, icon, markerType, markerSize, markerAnchor,extraClasses, shadowSize, shadowAnchor, markerPriority</query>
    </search>
    <option name="leaflet_maps_app.leaflet_maps.allPopups">0</option>
    <option name="leaflet_maps_app.leaflet_maps.animate">0</option>
    <option name="leaflet_maps_app.leaflet_maps.cluster">0</option>
    <option name="leaflet_maps_app.leaflet_maps.contextMenu">1</option>
    <option name="leaflet_maps_app.leaflet_maps.criticalThreshold">80</option>
    <option name="leaflet_maps_app.leaflet_maps.defaultHeight">800</option>
    <option name="leaflet_maps_app.leaflet_maps.drilldown">1</option>
    <option name="leaflet_maps_app.leaflet_maps.fullScreen">0</option>
    <option name="leaflet_maps_app.leaflet_maps.layerControl">1</option>
    <option name="leaflet_maps_app.leaflet_maps.layerControlCollapsed">0</option>
    <option name="leaflet_maps_app.leaflet_maps.mapCenterLat">$lat$</option>
    <option name="leaflet_maps_app.leaflet_maps.mapCenterLon">$long$</option>
    <option name="leaflet_maps_app.leaflet_maps.mapCenterZoom">10</option>
    <option name="leaflet_maps_app.leaflet_maps.mapTile">http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png</option>
    <option name="leaflet_maps_app.leaflet_maps.maxClusterRadius">25</option>
    <option name="leaflet_maps_app.leaflet_maps.maxSpiderfySize">100</option>
    <option name="leaflet_maps_app.leaflet_maps.maxZoom">19</option>
    <option name="leaflet_maps_app.leaflet_maps.measureActiveColor">#00ff00</option>
    <option name="leaflet_maps_app.leaflet_maps.measureCompletedColor">#0066ff</option>
    <option name="leaflet_maps_app.leaflet_maps.measureIconPosition">topright</option>
    <option name="leaflet_maps_app.leaflet_maps.measureLocalization">en</option>
    <option name="leaflet_maps_app.leaflet_maps.measurePrimaryAreaUnit">sqmeters</option>
    <option name="leaflet_maps_app.leaflet_maps.measurePrimaryLengthUnit">kilometers</option>
    <option name="leaflet_maps_app.leaflet_maps.measureSecondaryAreaUnit">sqmiles</option>
    <option name="leaflet_maps_app.leaflet_maps.measureSecondaryLengthUnit">meters</option>
    <option name="leaflet_maps_app.leaflet_maps.measureTool">0</option>
    <option name="leaflet_maps_app.leaflet_maps.minZoom">5</option>
    <option name="leaflet_maps_app.leaflet_maps.multiplePopups">0</option>
    <option name="leaflet_maps_app.leaflet_maps.pathColorList">#0003F0,#D43C29,darkgreen,0xe2d400,darkred,#23A378</option>
    <option name="leaflet_maps_app.leaflet_maps.rangeOneBgColor">#65a637</option>
    <option name="leaflet_maps_app.leaflet_maps.rangeOneFgColor">#65a637</option>
    <option name="leaflet_maps_app.leaflet_maps.rangeThreeBgColor">#65a637</option>
    <option name="leaflet_maps_app.leaflet_maps.rangeThreeFgColor">#65a637</option>
    <option name="leaflet_maps_app.leaflet_maps.rangeTwoBgColor">#65a637</option>
    <option name="leaflet_maps_app.leaflet_maps.rangeTwoFgColor">#65a637</option>
    <option name="leaflet_maps_app.leaflet_maps.scrollWheelZoom">1</option>
    <option name="leaflet_maps_app.leaflet_maps.showPathLines">0</option>
    <option name="leaflet_maps_app.leaflet_maps.singleMarkerMode">0</option>
    <option name="leaflet_maps_app.leaflet_maps.spiderfyDistanceMultiplier">1</option>
    <option name="leaflet_maps_app.leaflet_maps.warningThreshold">55</option>
    <option name="refresh.display">none</option>
   </viz>
</panel>
0 Karma
Get Updates on the Splunk Community!

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...