I'm trying to achieve This maps effect on my system.
I have a database of properties from all over a given country stored with their Longitude and Latitude.
When a user searches (Google Places) for properties within a given city in that country, the system should query and generate a map with markers from that city only and show a boundary around that city.
I am using the city coordinates to query the stored longitudes and latitudes of the properties.
Problem
My query seems to include results from other cities too resulting in markers that fall outside the city boundary.
My Research
I followed This Link that uses Google Maps Bounds, but It is not sufficient since the city boundary is dynamic and different from the Map Bounds.
Sample MySql Query
//$min_lat,$max_lat,$min_lng,$max_lng are city coordinates gotten from google maps
//The CAST is because property coordinates are stored in VARCHAR format instead of FLOAT
SELECT properties.*
FROM properties
WHERE (CAST(properties.lat AS DECIMAL(10,7)) >= '$min_lat' AND CAST(properties.lat AS DECIMAL(10,7)) <= '$max_lat')
AND (CAST(properties.lng AS DECIMAL(10,7)) >= '$min_lng' AND CAST(properties.lng AS DECIMAL(10,7)) <= '$max_lng')