简体   繁体   中英

Google Maps Api v3 error

After further reading, trial and error and searching for solutions that i can get to fit has failed.

I have a KML file, which displays the locations I want, the serious problem is I can not figure out how to get the search input element to work with the Google Maps API.

I have tried onclick="findplace" But I can not get the infowindow to appear.

I am basically trying to add a search function to my list of maps (from the KML file) and not big list of places that Google places offer. Am starting to wonder if this is even possible as I can not find a an example online which is the same.

JavaScript is not a strong area for me, is there a way to make my custom map searchable?

I'm guessing you need to search through your list of locations in the KML file and you can't know in advance what exactly it contains. To do this you need to access the content of the KML file through the google maps API or directly from the file itself.

There doesn't seem to be any method to access the individual objects within a KML file (see discussions here and here ) via the API. If the KML file originates from the same domain as your page then it would be possible to load the KML file and parse it as a straight XML file (see here ). Then you could search your parsed results and do what you need to do on the map (maybe send a click to the marker coordinate to show the infowindow). If it sits on another domain then you would need to retrieve the file via a server side call.

Does this sound like what you are trying to achieve?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM