Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Maps API V3: search markers

I am building a google map for a client and they want to be able to search for the markers that I have already added to the map.

I have already built the V3 API map that takes the markers from a MySQL table and pushes them into a marker array, but I am struggling to set up a search box that will list out any matches to the search query.

Anyone had any experience of this or able to help me?

like image 930
Matt P Avatar asked May 01 '12 22:05

Matt P


1 Answers

You would be best served by maintaining your own dataset of pins that have been pulled from the database and handling the searching of them in your own code. To implement you would need to save the reference to the pin you are creating for each location in that dataset. So get the locations from the DB, save locally, add them to the map, update the local datastore with the reference to the created pin, then hook your search to your dataset, and finally center or whatever you want to happen on the map pin reference you have saved for that result.

This google walkthrough is a good overview of this type of solution. https://developers.google.com/maps/articles/phpsqlsearch_v3?csw=1#creating-the-table

like image 79
Frank Phillips Avatar answered Oct 05 '22 16:10

Frank Phillips