Google Map Search POIs along Route

2,155 views
Skip to first unread message

Tejas B

unread,
May 30, 2011, 3:08:34 PM5/30/11
to Google Maps JavaScript API v3
Hi all,

This might be an age old question, but here it goes again.

I am looking for some examples of how to display POIs from database
for a route between two points. I have looked at a few examples but
either they are copyrighted, or not enough description to tell me how
it works.

I have looked at the Routeboxer and tried to integrate it with the
PHPSQl search examples. It sounds very straight-forward but unfort.
isn't so or I am doing something wrong.

Any more examples or code samples are appreciated.

Thanks,
-tejas

davie

unread,
May 31, 2011, 2:26:07 PM5/31/11
to Google Maps JavaScript API v3

michaeld42

unread,
May 31, 2011, 3:19:29 PM5/31/11
to Google Maps JavaScript API v3
This is one of those problems that is easy to describe but not so easy
to code.

Maybe the simplest to code is, once you have the bounds from
Routeboxer, get an XML file from the database containing all the
markers and loop through each marker, testing if the Routeboxer bounds
contains the LatLng of the marker. On http://www.roadtripamerica.com/maps/mapwizard.php
I do it slightly differently, because I have each marker indexed by
distance from three standard points. I use a MySQL search to narrow
the prospective marker list, then test each marker individually.

Hope this helps...
Michael

Tejas B

unread,
Jun 1, 2011, 1:08:14 PM6/1/11
to Google Maps JavaScript API v3
Hey Michael,

Yes, I have realized that the coding part is much demanding than the
single line requirement.

Do you have some more directions for me? I have been banging my head
against wall with this with no luck at all. You example is pretty much
what I need to do.

Thanks,
-tejas

On Jun 1, 12:19 am, michaeld42 <michael...@aol.com> wrote:
> This is one of those problems that is easy to describe but not so easy
> to code.
>
> Maybe the simplest to code is, once you have the bounds from
> Routeboxer, get an XML file from the database containing all the
> markers and loop through each marker, testing if the Routeboxer bounds
> contains the LatLng of the marker. Onhttp://www.roadtripamerica.com/maps/mapwizard.php

michaeld42

unread,
Jun 2, 2011, 12:19:35 PM6/2/11
to Google Maps JavaScript API v3

Tejas,

There must be a lot of different ways to do this, and the 'best' way
would depend on a lot of different factors, but Routeboxer produces a
set of LatLngBounds objects, so to use that I'd proceed as I already
outlined above:
1. Use Routeboxer to get set of bounds
2. Get list of all markers from database
3. Loop through the markers and bounds to see if each marker is in any
of the bounds (use the 'contains' method documented in the API).

- Michael

KP

unread,
Jun 27, 2012, 5:34:05 PM6/27/12
to google-map...@googlegroups.com
Michael,

Can you provide instructions for step 3? I have scoured the web for an example of Routeboxer in action so that I can build a tool that will let people map from "A" to "B" and find POIs within a certain distance. I've copied the Google code and recreated it, but all I get is a map with a box drawn on it. 

Thanks for any help you can provide!

- KP

Barry Hunter

unread,
Jun 27, 2012, 5:39:43 PM6/27/12
to google-map...@googlegroups.com
The example on the documentation page

shows how to loop though the 'boxes' retured from the boxer call. 

You would probably fire off a ajax request off to your server, which would perform a bounding box search, get the results. One search per box. 

The actual demo
just calls drawBoxes with the list, you need a similar function. 




--
You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-maps-js-api-v3/-/eAYgSTGJFuMJ.

To post to this group, send email to google-map...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.

KP

unread,
Jun 27, 2012, 6:04:27 PM6/27/12
to google-map...@googlegroups.com
Barry,

Thanks so much for the quick response. I'm a non-dev looking for a layperson's tutorial or an example that actually does this looping. What part of the code does the looping? This will help me do some cutting and pasting into what I've got so far.

I've gotten as far as creating a map that displays all of my POIs. Now, I'm trying to figure out how to only pull the POIs that fall within the range of the route and the box, and I just haven't been able to find a walk-through or an example that is at my level of technical ability. Just to see if I could do it, I added the RouteBoxer.js code to my existing map. I also copied and pasted the code on the examples.html page in. When I do this, no map is generated.

Any advice you can offer is much appreciated!

- KP




To post to this group, send email to google-maps-js-api-v3@googlegroups.com.
To unsubscribe from this group, send email to google-maps-js-api-v3+unsub...@googlegroups.com.

Barry Hunter

unread,
Jun 27, 2012, 6:16:36 PM6/27/12
to google-map...@googlegroups.com
Well I can't help you with your actual code, because I can't read your mind to see it. 

To be frank, this isnt a 'trival' topic, so if you dont have much experience coding, its might well be trickly to get it right. Might be worth looking for a developer (no I am not offering!) 


But inspired by this thread, I just built a quick rough demo

Loads photographs along the route (only have photos within the British Isles). The boxes, have default values that work, just press the Submit button. 


The main part that needs work, is how to limit the number of results. Currently it just takes 100 divided by number of boxes. Then each search is fired off, asking for that many results. It does also enforce a minimum, to prevent 0 being used :)

This is not ideal because if, there is uneven coverage, say a large number of results in one box, but few in others. Will end up not showing many results, because the busy box, will still have the same limit. 

To combat, that could actully ask for many more results from each box, but reduce the number of results actully displayed, once you have all the results back. 


Alternatively could send all the bboxes to the server, and let it use them all when finding images. It could then take care of enforcing a good limit. 


Doing the server side component, is something can'y really help you with. 



To view this discussion on the web visit https://groups.google.com/d/msg/google-maps-js-api-v3/-/6HjC4Y7YraAJ.

To post to this group, send email to google-map...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.

KP

unread,
Jun 27, 2012, 6:46:59 PM6/27/12
to google-map...@googlegroups.com
Hi, Barry. Cool example!

Short of a full-blown tutorial, I'm interested in seeing an example page of HTML code, including the code for the Google Maps API, that:
  • Lets you get a route from A to B.
  • Uses the Routeboxer method.
  • Runs this method against a MySQL source in order to display only POIs that are within a certain distance. 
I totally understand that this is not a trivial issue, but seeing example code that does the above will let me test whether I can pull off this type of page on my own. Thanks for any advice you can offer on finding this type of example.

- KP



On Wednesday, June 27, 2012 6:16:36 PM UTC-4, barryhunter wrote:
Well I can't help you with your actual code, because I can't read your mind to see it. 

To be frank, this isnt a 'trival' topic, so if you dont have much experience coding, its might well be trickly to get it right. Might be worth looking for a developer (no I am not offering!) 


But inspired by this thread, I just built a quick rough demo

Loads photographs along the route (only have photos within the British Isles). The boxes, have default values that work, just press the Submit button. 


The main part that needs work, is how to limit the number of results. Currently it just takes 100 divided by number of boxes. Then each search is fired off, asking for that many results. It does also enforce a minimum, to prevent 0 being used :)

This is not ideal because if, there is uneven coverage, say a large number of results in one box, but few in others. Will end up not showing many results, because the busy box, will still have the same limit. 

To combat, that could actully ask for many more results from each box, but reduce the number of results actully displayed, once you have all the results back. 


Alternatively could send all the bboxes to the server, and let it use them all when finding images. It could then take care of enforcing a good limit. 


Doing the server side component, is something can'y really help you with. 
On Wed, Jun 27, 2012 at 11:04 PM, KP
Barry,
To unsubscribe from this group, send email to google-maps-js-api-v3+unsubscri...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Barry Hunter

unread,
Jun 27, 2012, 7:07:21 PM6/27/12
to google-map...@googlegroups.com
Well the example I just posted does exactly that. 

Actully not quite, its not talking to a mysql database, its actully using sphinxsearch as the 'database'.  


You need a 'API' that accepts parameters by URL, performs the search, and then returns the results back to the application. Its old, but
this is a basic XML api powered by mysql. Back from the days before JSON was popular, so it used XML !??!

Wouldn't recommend coping that directly - but it might be useful to show what such a script would have to do. 


To view this discussion on the web visit https://groups.google.com/d/msg/google-maps-js-api-v3/-/sAV0s2yV9q4J.

To post to this group, send email to google-map...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages