简体   繁体   English

没有php代理的跨域

[英]Cross-domain without php proxy

In this page I have embedded a Google Map using Javascript and loading data from a static KML file loaded on my domain. 页面中,我已使用Java脚本嵌入了Google Map,并从域中加载的静态KML文件加载了数据。 I want to improve my map loading data from a dynamic KML file stored on google servers (Network link), but this cannot be done directly because of cross-domain restriction. 我想改善从Google服务器(网络链接)上存储的动态KML文件加载地图的数据,但是由于跨域限制,因此无法直接完成此操作。 I tried using a php proxy but my hosting service doesn't allow this. 我尝试使用php代理,但托管服务不允许这样做。 (don't ask to me why, I get ERROR 406 response and the customer service said that this kind of request are blocked by their filters!) (不要问我为什么,我得到ERROR 406响应,客户服务人员说这种请求被其过滤器阻止了!)

So, how can I do cross domain without a proxy? 那么,没有代理我如何跨域?

This is the link that give be the kml file: http://maps.google.com/maps/ms?authuser=0&vps=2&hl=en&ie=UTF8&lr=lang_en|lang_fr|lang_it&oe=UTF8&msa=0&msid=201512616711333791415.0004c56e9ca3fb71ba551&output=kml 这是kml文件的链接: http ://maps.google.com/maps/ms?authuser=0&vps=2& hl= zh-CN&ie=UTF8&lr=lang_en|lang_fr|lang_it&oe=UTF8&msa=0&msid=2015126167113793791415.0004c56e9ca3fb71ba551&output=

Thank you! 谢谢!

You can use JSONP to overcome the cross domain problem. 您可以使用JSONP来克服跨域问题。 Look at these links: 查看以下链接:

http://www.jquery4u.com/json/jsonp-examples/ http://www.jquery4u.com/json/jsonp-examples/

http://www.ibm.com/developerworks/library/wa-aj-jsonp1/ http://www.ibm.com/developerworks/library/wa-aj-jsonp1/

If your kml is being displayed by KmlLayer in the Google Maps API v3 (or GGeoXml in v2, or Google Maps), as long as it is publicly available it will work, there are no cross-domain issues. 如果您的kml由KmlLayer在Google Maps API v3(或v2中的GGeoXml,或Google Maps)中显示,则只要它可以公开使用,就不会出现跨域问题。 Maybe you are parsing it yourself, if so, that isn't stated in your question. 也许您是自己解析的,如果这样,您的问题中没有提到。

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

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