title: Search for location in database that fall within given (multiple) lat and lon values
body: <p>I am trying to use Google's drawing tools (<a href="https://developers.google.com/maps/documentation/javascript/examples/drawing-tools" rel="nofollow noreferrer">https://developers.google.com/maps/documentation/javascript/examples/drawing-tools</a>), which allows me to draw on the map and get the coordinates. </p>
  
  <p>Here is fiddle-
  <a href="https://jsfiddle.net/mg0t5x8n/2/" rel="nofollow noreferrer">https://jsfiddle.net/mg0t5x8n/2/</a></p>
  
  <pre><code>function initMap() {
    var map = new google.maps.Map(document.getElementById('map'), {
      center: {lat: 52.908978, lng: -1.451871},
      zoom: 14
    });
  
  
    var drawingManager = new google.maps.drawing.DrawingManager({
      drawingMode: google.maps.drawing.OverlayType.POLYLINE,
      drawingControl: true,
      drawingControlOptions: {
        position: google.maps.ControlPosition.TOP_CENTER,
        // drawingModes: ['marker', 'circle', 'polygon', 'polyline', 'rectangle']
        drawingModes: ['polyline']
      },
      markerOptions: {icon: 'https://developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png'},
      circleOptions: {
        fillColor: '#ffff00',
        fillOpacity: 1,
        strokeWeight: 5,
        clickable: false,
        editable: true,
        zIndex: 1
      }
    });
    drawingManager.setMap(map);
  
    google.maps.event.addListener(drawingManager, 'polylinecomplete', function(line) {
      console.log(line.getPath().getArray().toString());
      alert(line.getPath().getArray().toString());
    });
  };
  initMap();
  </code></pre>
  
  <p>After connecting the last line with the start of the first line you drew, you get list of coordinates. 
  After getting these coordinates i need to run a query in the database (where i have list of locations, with lat and lon values for each) which retrieves all the locations that fall within the given points. </p>
  
  <p>I'm not sure if this is possible with sql or requires something different. </p>
  
  <p>Sorry if the question is bit vague, I'm at a very early stage with this and just wanted to get some info see if its possible to do and if so how i would go about it.</p>
  
  <p>****** UPDATE ****** </p>
  
  <p>After retrieving the lat and lon value of the polygon - I came across this php function(<a href="http://assemblysys.com/php-point-in-polygon-algorithm/#comment-1243" rel="nofollow noreferrer">http://assemblysys.com/php-point-in-polygon-algorithm/#comment-1243</a>). Its sort of doing what i was after - some modification needed. Might be helpful to someone else looking to achieve something similar. </p>