离线使用Google Maps V3,例如与缓存清单? [英] Using Google Maps V3 offline, e.g. with cache-manifest?
问题描述
我正在编写一个HTML5移动应用程序,该应用程序使用带有自定义OpenStreetMap图块的Google Maps V3。
OSM图块(来自 tile.openstreetmap.org
)被设置为缓存超过24小时,并且我为我的所有HTML / JS / CSS使用缓存清单。
因此,应用程序理论上可以脱机使用,除非Google地图界面在离线时不开心。
它总是希望通过 http://maps.google.com/maps/api/js?sensor=致电Google地图服务器false& region = GB
- 如果失败,Google地图无法加载。
我可以使用Google Maps V3 API离线吗?
我可以缓存清单 http://maps.google.com/maps/api/js?sensor=false®ion=GB
,或者这会是一个不好的举动?
(对不起,这是一个初学者的问题,让我知道如果我可以更好地解释!)
谷歌编码人员自己已经解决了这个问题,不幸的是这些信息没有得到很好的传播。但是,您可以使用缓存清单来完成您所描述的内容。
必填读物
- 首先在这里查看Google Code blogpost: http://googlecode.blogspot.com/2010/04/google-apis-html5-new-era-of-mobile.html
- 然后有一个阅读密苏里州自己的帖子: http:
$ b技术
- 您必须缓存Google地图使用的每个网址 / li>
- 使用方法与Chrome和Firefox的顽固缓存方法进行对抗,将其从离线网站中移除
- 所有自定义项必须位于JavaScript中的客户端
li>
您的缓存文件将如下所示(按照密苏里州的规定):
CACHE MANIFEST
/ map / mobile / examples / template.aspx
/map/mobile/examples/template.css
/map/mobile/examples/template.js
网络:
http://maps.gstatic.com /
http://maps.google.com/
http://maps.googleapis.com/
http://mt0.googleapis.com/
http:/ /mt1.googleapis.com/
http://mt2.googleapis.com/
http://mt3.googleapis.com/
http://khm0.googleapis.com/
http://khm1.googleapis.com/
http://cbk0.googleapis.com/
http://cbk1.googleapis.com/
http:// www .google-analytics.com /
http://gg.google.com/
注意事项
您需要完全基于HTML5,并认识到这会对用户造成的影响。如果您的用户在浏览器标准/设备上更新,或者您可以控制用户的选择,这种情况非常方便。
希望这有助于您。
I'm writing an HTML5 mobile application that uses Google Maps V3 with a custom layer of OpenStreetMap tiles.
The OSM tiles (from tile.openstreetmap.org
) are set to cache for just over 24 hours, and I'm using a cache-manifest for all my HTML/JS/CSS.
So the application could in theory be used offline, except the Google Maps interface isn't happy when offline.
It always wants to call to the Google Maps server at http://maps.google.com/maps/api/js?sensor=false®ion=GB
- when this fails, Google Maps fails to load.
Is there any way to use Google Maps V3 API offline?
Could I cache-manifest http://maps.google.com/maps/api/js?sensor=false®ion=GB
, or would that be a bad move?
(Sorry for this rather beginner question, let me know if I can explain better!)
Google coders themselves have tackled this problem and unfortunately the information isn't well disseminated. But yes you can use cache-manifest to do exactly what you've described.
Required Readings
- First take a look at the Google Code blogpost here: http://googlecode.blogspot.com/2010/04/google-apis-html5-new-era-of-mobile.html
- Then have a read at Missouri State's own post: http://blogs.missouristate.edu/web/2010/05/12/google-maps-api-v3-developing-for-mobile-devices/
The Technique
- You must cache every URL used by Google Maps
- Employ methods to battle Chrome's and Firefox's stubborn caching methods by removing it from "offline websites"
- All customizations must be client-side in javascript
Your cache file will look like (as per Missouri State):
CACHE MANIFEST
/map/mobile/examples/template.aspx
/map/mobile/examples/template.css
/map/mobile/examples/template.js
NETWORK:
http://maps.gstatic.com/
http://maps.google.com/
http://maps.googleapis.com/
http://mt0.googleapis.com/
http://mt1.googleapis.com/
http://mt2.googleapis.com/
http://mt3.googleapis.com/
http://khm0.googleapis.com/
http://khm1.googleapis.com/
http://cbk0.googleapis.com/
http://cbk1.googleapis.com/
http://www.google-analytics.com/
http://gg.google.com/
Caveats
You will need to be entirely HTML5-based and recognize the impacts this will have on your users. This situation is handy where either your users are up-to-date on browser standards/devices or you have control over user choices.
Hope this helps.
这篇关于离线使用Google Maps V3,例如与缓存清单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!