Skip to main content
Post Merged (destination) from gis.stackexchange.com/questions/311930/…
Post Merged (destination) from gis.stackexchange.com/questions/311930/…
added 131 characters in body
Source Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

How to get Making button clickclickable to perform function in Leaflet?

I am trying to create buttons that will initiate a flyTo. I can click the buttons on the page but they do nothing

action functions:

<script>
      function Action(){
      map.flyto([43.372000,-80.987697], 13);
      }
</script>
<script>
      function Action1(){
      map.flyto([43.370627,-80.998735], 13);
      }
</script>
<script>
      function Action2(){
      map.flyto([43.377328,-80.963505], 13);
      }
</script>
<script>
      function Action3(){
      map.flyto([43.388931,-80.972062], 13);
      }
</script>

Buttons

<div class = "leaflet-bottom leaflet-left" style="pointer-events: auto">
 <button onClick="Action()" block>Douglas Flood Risk Area</button>
 <button onClick="Action1()" block>Avondale Flood Risk Area</button>
 <button onClick="Action2()" block>Millenium Park Flood Risk Area</button>
 <button onClick="Action3()" block>Mornington Flood Risk Area</button>
</div>

I have added 4 buttons into my leaflet map and none of them can actually be clicked.

Is there a way to make them clickable?

How to get button click to perform function in Leaflet

I am trying to create buttons that will initiate a flyTo. I can click the buttons on the page but they do nothing

action functions:

<script>
      function Action(){
      map.flyto([43.372000,-80.987697], 13);
      }
</script>
<script>
      function Action1(){
      map.flyto([43.370627,-80.998735], 13);
      }
</script>
<script>
      function Action2(){
      map.flyto([43.377328,-80.963505], 13);
      }
</script>
<script>
      function Action3(){
      map.flyto([43.388931,-80.972062], 13);
      }
</script>

Buttons

<div class = "leaflet-bottom leaflet-left" style="pointer-events: auto">
 <button onClick="Action()" block>Douglas Flood Risk Area</button>
 <button onClick="Action1()" block>Avondale Flood Risk Area</button>
 <button onClick="Action2()" block>Millenium Park Flood Risk Area</button>
 <button onClick="Action3()" block>Mornington Flood Risk Area</button>
</div>

Making button clickable to perform function in Leaflet?

I am trying to create buttons that will initiate a flyTo. I can click the buttons on the page but they do nothing

action functions:

<script>
      function Action(){
      map.flyto([43.372000,-80.987697], 13);
      }
</script>
<script>
      function Action1(){
      map.flyto([43.370627,-80.998735], 13);
      }
</script>
<script>
      function Action2(){
      map.flyto([43.377328,-80.963505], 13);
      }
</script>
<script>
      function Action3(){
      map.flyto([43.388931,-80.972062], 13);
      }
</script>

Buttons

<div class = "leaflet-bottom leaflet-left" style="pointer-events: auto">
 <button onClick="Action()" block>Douglas Flood Risk Area</button>
 <button onClick="Action1()" block>Avondale Flood Risk Area</button>
 <button onClick="Action2()" block>Millenium Park Flood Risk Area</button>
 <button onClick="Action3()" block>Mornington Flood Risk Area</button>
</div>

I have added 4 buttons into my leaflet map and none of them can actually be clicked.

Is there a way to make them clickable?

Source Link
PVar
  • 81
  • 1
  • 2
  • 8

How to get button click to perform function in Leaflet

I am trying to create buttons that will initiate a flyTo. I can click the buttons on the page but they do nothing

action functions:

<script>
      function Action(){
      map.flyto([43.372000,-80.987697], 13);
      }
</script>
<script>
      function Action1(){
      map.flyto([43.370627,-80.998735], 13);
      }
</script>
<script>
      function Action2(){
      map.flyto([43.377328,-80.963505], 13);
      }
</script>
<script>
      function Action3(){
      map.flyto([43.388931,-80.972062], 13);
      }
</script>

Buttons

<div class = "leaflet-bottom leaflet-left" style="pointer-events: auto">
 <button onClick="Action()" block>Douglas Flood Risk Area</button>
 <button onClick="Action1()" block>Avondale Flood Risk Area</button>
 <button onClick="Action2()" block>Millenium Park Flood Risk Area</button>
 <button onClick="Action3()" block>Mornington Flood Risk Area</button>
</div>