google maps offline: not tiles but javascript - 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.

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.

You could use OpenStreetMaps instead, it can be used offline: http://wiki.openstreetmap.org/wiki/Offline_Openstreetmap

Related

How to notify on upcoming turn google maps API v3

This may be very obvious to others but I am struggling with how to achieve this and can't seem to find it in the docs or using Google, this may be down to a badly worded query.
What I am trying to do is create a Route on a map and track my progress on it as I navigate and like the navigate function in google maps send a notification of the turn when within a x number of meters, similar to voice in google maps but I just want to get the text.
Is this possible with the Javascript API v3 out of the box? If so can someone point me to the relevant documentation or tutorials
if not out of the box, can someone suggest a design pattern or some pseudo code to do this.
What I am trying to do at the moment is.
Get my routes in Steps ( gps & text )
Get the next Step ( gps & text )
When current location is within 10m notify
when current location is past notify to update to next step & repeat
This feels like I am oversimplifying it and I am also struggling with how to correctly get the distance to next step. I know I can get the distance between 2 coordinates but is the a more accurate way to do so as to avoid getting an "as the crow fly's" distance?
I am trying to do this with Google maps api v3 in an Ionic AP using the Cordova GeoLocation plugin
Again Apologies if this is obvious to anyone else but I am struggling to find any relevant examples. If for some reason this is not easily done with google maps I am open to other open source or free frameworks that I can access via javascript
There is no out of the box solution. You would have to use both the Maps API and the Directions API. Directions returns routes in legs so you can use that to determine each step and get the user's location via Geolocation.
However, this might be against Terms of Service
No Navigation, Autonomous Vehicle Control, or Enterprise
Applications. You must not use the Service or Content with any
products, systems, or applications for or in connection with any of
the following:
(i) real-time navigation or route guidance, including but not limited
to turn-by-turn route guidance that is synchronized to the position of
a user's sensor-enabled device.

Google Maps API for queries, not rendering

Is there a way to go through the process of creating a google map without all the rendering stuff? I have a project in which I need to do some spacial queries on a map, and I'm using the Maps API for it, but I don't actually have to display the map.
I know I could obviously just do display: none, but if it's possible, I'd like a solution that doesn't waste a bunch of client processing power to draw all of the map stuff in the first place, whether it actually gets rendered or not.
Apparently that is not allowed by the Google Maps/Google Earth APIs Terms of Service, section 10.1 g)
Quote:
(g) No Use of Content without a Google Map. You must not use or display the Content without a corresponding Google map, unless you are explicitly permitted to do so in the Maps APIs Documentation, or through written permission from Google.

Converting Flash Google Maps API to Javascript based in Flash?

I was given an older program to work on, and it uses the Google Maps API for Flash. The application is built in Flash CS5 and cannot be converted to anything else but Flash (as it's a piece of a larger Flex application that takes Flash built swfs and loads them into a Flex built larger application) so I can't use a pure Javascript approach. And also I don't know any Javascript, I'm basically a pure Flash/Flex developer, heh.
Is there an "easy" way to convert the application from the Flash based API to the Javascript based API? I don't even know where to start, I'm just out of college, this is my first real big project, and I'm the only Flash dev
Otherwise I'm kind of stuck, because the API key expired, Google doesn't give out new keys and they aren't answering my request to renew the key. I was also looking into the MapQuest Flash API and converting it over to that, however, I'm not sure.
I also want to note I can't use a web view, as content needs to be shown on top, and the entire map needs to be integrated into the SWF, I should only be pulling data from the API and displaying it in Flash as a Flash element. I've used a web set up before and it would not be appropriate for my needs for this project.
Converted the application to MapQuest's API. I was expecting a nightmare and I actually was very surprised at how smooth the transition went (as you can see by the time stamps). Didn't take me long at all.
Functionality is comparable, and it boiled down to just changing some function names to get the same functionality for simpler things, and then a bit of digging around and making everything work.
See my answer to the duplicate question: Embedding Google Maps in Flash - I have implemented Bing, Google and MapQuest JavaScript maps and their elevation services in Flash - the full post (with code) was too long so it is here: http://pastebin.com/Jzq5E06F

Google Maps api custom tiles for fictional video game world

I want to use the Google Maps v3 api to generate an interactive Google Map interface that uses custom tiles for a map from a video game. The app needs to be able to zoom-in out and display the proper tiles for each zoom level as well.
I'm looking for some resources or a tutorial on how to accomplish this. The Google Maps v3 API appears to only discuss using custom tiles that lay on top of the normal Google Maps tiles. That wouldn't make sense in my application since my map is for a fictional world and wouldn't line up with anything in the real world maps. Perhaps I'm just not seeing what I need in the API guide...
Check out the ImageMapType class in the reference. There's a nifty example showing Moon tiles.
One of my favourite applications is The Internet map, the developer wrote a pretty sweet article on how it was developed.
You need to either cut up your custom game map image into the appropriate file/directory structure that makes integration into Maps API easy (here's an example using Photoshop and some example HTML/JS code). Or use a more friendly tool like TileMill, but this expects data in a standard spatial data format and you probably don't have your game map stored in such a format. If you can go that route, they also provide a Node.js-based server called TileServe that makes integration a cinch.
If you are expecting a boatload of traffic, then maybe look at Google Maps Engine to host your custom game map image directly in Google's infrastructure.

how does the google maps identifies the roads(paths)?

when i went through the source code of the google maps page i've realized that the whole map is formed by small tiles of images. But how does the javascript identifies the roads on the google maps to show the way from ourlocation to destination??
I couldn't tell you HOW it works, it is a very complex application but all the work is done on the server and the reason the page shows the map as images is purely down to the limited ways in which a browser can display content.
Google have several layers with information about streets, roads, etc... when you use google maps only show a "graphical representation" of their data in bitmap format, but they need a "vectorial" layer that we don't see it.
Calculate routing is a very complex infraestructure problem in GIS server, for example, with Geoserver and PostGIS you can use Dijkstra Routing with Pgdijkstra.
It's very complex question, for a short answer.

Categories