Solved

Return Records based on selected map area

Posted on 2011-02-11
2
466 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Add shadow behind div 5 25
Un-Indent Setting Notepad++ 3 18
How to pass JavaScript generated HTML text form values to PHP? 5 38
Html input text color the frame line 2 20
Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

840 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