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?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With