php,javascript,mysql splitting big query to google maps
first question here :)
I have a table with over million locations (id|address|longitude|latitude).
User can enter an address and he gets the nearest locations by 5km radius
in google map.
My select query :
$result = mysql_query("SELECT *, ( 6371 * acos( cos( radians(".$lat1.") )
* cos( radians( lat ) ) * cos( radians( lng ) - radians(".$lng1.") ) +
sin( radians(".$lat1.") ) * sin( radians( lat ) ) ) ) AS distance FROM
star HAVING distance < ".$rad." ORDER BY distance");
results on table, inside javascript <>
while ($row = mysql_fetch_array($result)) {
echo "
var marker".$row{'id'}." = new google.maps.Marker({
position: new google.maps.LatLng(".$row{'lat'}." , ".$row{'lng'}."),
map: map
});
var infowindow".$row{'id'}." = new google.maps.InfoWindow({
content: 'City : ".$row{'city'}.", Address : ".$row{'address'}." , Lat
: ".$row{'lat'}." , Lng : ".$row{'lng'}."'
});
google.maps.event.addListener(marker".$row{'id'}.", 'click', function() {
infowindow".$row{'id'}.".open(map, marker".$row{'id'}.");
});
";
}
My problem is when it gets over 10 locations, its doesn't show the google
map.. I dont want to use LIMIT 0,10, I wanna show all the results.
How do I split the query to search each time 10% from the big table?
Something lke putting the markers on runtime after the page loads.
No comments:
Post a Comment