Arash Yazdani Arash Yazdani - 1 year ago 188
Javascript Question

how to select markers in the polygon from mysql

i'm saving markers coordinates in mysql like below image

enter image description here

what i need is when user draw on maps like below image

enter image description here

i could get the shape and select markers in the shape from mysql and create a query.

for example:

$query= mysql_query("SELECT

FROM table WHERE Coordinates in the polygon");

i belive i need use ajax. and i'm using google maps v3

is this even possible to do that ?

PLEASE HELP, Any idea that i could somthing like that other way ??

Answer Source

Google maps does not provide GIS functions to select the coordinates inside a polygon. You could do using the spatial extension ( data type GEOMETRY) for mysql .. and for this you can go into that .. for mysql doc.

A simple way to select locations (points) in google maps is to use the extreme values of the coordinates of the polygon points to get the equivalent to the coordinates of the rectangle that contains the polygon vertices and then perform a select

  select location  
  from my_table 
  where location_lat >= minLat_polygon
  AND location_lat  <=  maxLat_poligon
  AND location_lng  <=  maxLng_polygon
  AND location_lng  >=  minLng_polygon
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download