简体   繁体   English

Google Maps Api v3错误

[英]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. 我有一个KML文件,其中显示了我想要的位置,严重的问题是我无法弄清楚如何使搜索输入元素与Google Maps API一起使用。

I have tried onclick="findplace" But I can not get the infowindow to appear. 我已经尝试过onclick =“ findplace”,但无法显示信息窗口。

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. 我基本上是想将搜索功能添加到我的地图列表中(来自KML文件),而不是Google所提供地点的很大列表。 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? JavaScript对我而言不是一个强项,是否可以使我的自定义地图可搜索?

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. 我猜您需要在KML文件中的位置列表中进行搜索,而您无法事先知道其确切包含的内容。 To do this you need to access the content of the KML file through the google maps API or directly from the file itself. 为此,您需要通过Google Maps API或直接从文件本身访问KML文件的内容。

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. 似乎没有任何方法可以通过API访问KML文件中的单个对象(请参见此处此处的讨论)。 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 ). 如果KML文件与您的页面来自同一域,则可以加载KML文件并将其解析为纯XML文件(请参见此处 )。 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? 这听起来像您要达到的目标吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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