Solved

Return Records based on selected map area

Posted on 2011-02-11
2
454 Views
Last Modified: 2012-05-11
Dear Experts,

I appreciate this is a big ask, however we would like to introduce functionality into our real estate website which allows users to draw an area on a google map which upon form submission will query the database and return properties which fall within the selected area.

All the records within our database have latitude and longitude values but I have no idea where to start with regards returning these records.

We have a test page which allows users to draw an area on a map at the following URL:
http://www.bspc.co.uk/gbmap.asp

However, I wondered if anyone could suggest how we can achieve the above using this?

Thanks


0
Comment
Question by:grantballantyne
2 Comments
 
LVL 40

Expert Comment

by:gurvinder372
ID: 34871426
using this you can get the latitude and longitude of a point on a map
http://www.tech-recipes.com/rx/2403/google_maps_get_latitude_longitude_values/

you can then fetch the records for that point
0
 
LVL 3

Accepted Solution

by:
Maximus5684 earned 500 total points
ID: 34919266
If the Google Maps API you are using returns the boundaries of the box that is drawn (assuming that it is a box), it should give them back in lat/long format. Have the page use AJAX to send these lat/long pairs back to a processing page. Have that page do the following:

 If it gives back four sets of lat/long pairs, pair down the identical latitudes and the identical longitudes to get the lat/long pair of the upper-left boundary point and the lower-right boundary point. If it only gives two lat/long pairs, you can skip that step. Take the latitudes and sort them in ascending order then search your database for any points between the upper and lower latitudes. This produces result set 1. Now take the longitudes and sort them in ascending order. Then search result set 1 for longitudes between the upper and lower longitudes. This will produce result set 2 which will include all of the points you're looking for. Now, use AJAX to send a message back to the calling page that includes all of the lat/long pairs for the points you want to place on the map. Have a JavaScript function on the page receive the results of the AJAX call and add points on the map tiles corresponding to the lat/long pairs.

That's the general overview. Detail of each of the steps are hard to define without knowing more about the Google Maps API and some details of your website's setup.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
FTP File permissions 1 30
Problem to picture file 3 40
Javascript generate change location 12 25
Cordova Camera plugin fails 2 19
Read about why website design really matters in today's demanding market.
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now