Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

google maps offline: not tiles but javascript

I have an HTML (phonegap) application that uses Google Maps API to display a map with markers. I want this app to be used offline. I know that Google Maps tiles can't be used offline (because of its license). However, what I want to do is use the map interface without the tiles.

When online -> tiles and markers displayed.

When offline -> only markers displayed.

However, the js loading of Google maps is complex, and I haven't managed to cache it.

Thanks.

like image 686
Mateu Avatar asked May 31 '13 14:05

Mateu


1 Answers

Caching google maps javascript is not allowed, that's because their payment system is based on how many times their javascript API are loaded by the users. One page refresh is equal to one google maps API call, and depending what kind of contract you made you just lost -1 from the total amount of API requests you have purchased.

How is Google Maps API for Business usage tracked and reported?

A single load of the Google Maps JavaScript API into a page. The JavaScript API is reloaded every time a page that uses the API is reloaded. User interactions with the map (eg. panning, zooming, changing map types) do not generate more page views. Note however that a page view is generated if the API is loaded into the page even if the API is not then used to display a map.

See https://developers.google.com/maps/documentation/business/faq#pageview

You could, of course contact google and try to ask some tailored business solution for your needs. I am not 100% sure what kind of things they offer if you contact them directly. But although, your request is somewhat impossible to fill since those UI generation codes also resides inside that google maps API javascript which you need.

So I would suggest that if you only need google maps interface when offline, take a moment and implement something similar with HTML/CSS/ (and some JS).. markers you could draw on canvas or use normal img's and positioning. If you need to implement dragging and zooming - it would be little bit more difficult but not impossible with canvas or some other techniques. But that being said it would just be easier to keep app online, we all have internet :) ? Making 1on1 matching dummy offline UI against google maps would be really painful process, when we consider the fact that google maps UI also changes overtime, like in their upcoming versions.

like image 166
Mauno Vähä Avatar answered Oct 01 '22 13:10

Mauno Vähä