title: Passing leaflet map object to a event
body: <p>i am using leaflet to display map in django template. i give latitude, longitude and radius and filter results based on that and try to add marker to map. how ever i couldnt create map markers since i dont know how to pass map object to event and also i wish to know how to get lat lng from the address in leaflet.</p>
  
  <p><strong>index.html</strong></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  {% load static %} {% load leaflet_tags %}
  &lt;head&gt;
      {% leaflet_js %} {% leaflet_css %}        
      &lt;style&gt;
      div#gis {
          height: 500px;
      }
      &lt;/style&gt;
      &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="{% static 'dist/leaflet.ajax.js' %}"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;      
      {% csrf_token %}
      &lt;label for="latitude"&gt;Latitude&lt;/label&gt;
      &lt;input type="number" name="latitude" id="latitude" step="any"&gt;
      &lt;br /&gt;
      &lt;label for="longitude"&gt;Longitude&lt;/label&gt;
      &lt;input type="number" name="longitude" id="longitude" step="any"&gt;
      &lt;br /&gt;
      &lt;label for="radius"&gt;Radius&lt;/label&gt;
      &lt;input type="number" name="radius" id="radius" step="any"&gt;
      &lt;br/&gt;
          &lt;button type="submit" onclick="myFunction()"&gt;Submit&lt;/button&gt;
          &lt;script type="text/javascript"&gt;
      let csrftoken = 
      document.cookie.replace(/(?:?:^|.*;\s*)csrftoken\s*\=\s* . 
      ([^;]*).*$)|^.*$/, "$1");   
  
      function myFunction(){
        lat= document.getElementById('latitude').value
        lon=document.getElementById('longitude').value
        rad=document.getElementById('radius').value          
     $.ajax({
       url: "{% url 'data' %}" + "? 
       latitude="+lat+"&amp;longitude="+lon+"&amp;radius="+rad,
       type: 'POST',
       dataType: 'json',
       headers: { "X-CSRFToken": csrftoken},
       contentType: 'application/json;charset=utf-8',          
  
      success:function(response){           
          response.features.map((map)=&gt;{
              Lat = map.geometry.coordinates[1]  
              Lon = map.geometry.coordinates[0]                
              L.marker([ Lat,Lon]).addTo(map)                  
          })
      },        
  })     
  }       
          &lt;/script&gt;
          {% leaflet_map "gis" %}  
  
      &lt;/body&gt;
      &lt;/html&gt;&gt;
  </code></pre>