Google Maps draw route without calling server - javascript

I have a bunch of routes stored in database. When a user visits a page, I want him to see all of these routes on a map. I would prefer that the Google Maps server not have to resolve the route from scratch every time.
I would like to store the route and simply print it to the map each time it's requested.
I found the Polyline object in Google Maps API and it seems that calling setMap() draws the Polyline onto the map without talking to the server.
Does anyone know if/how I would be able to confirm this?

Related

Is it possible to calculate a Bing Maps Route in C#, and then pass it to a Map in Javascript using MvC?

I am developing a Web Based Navigation app using Bing Maps and ASP MvC, and I found as well as being able to create a route in the view using JavaScript, it is possible to create a route in the C# controller using the Bing Maps Rest Toolkit, and then pass it over.
However, I have been unable to find any information as to how to actually display the passed route on the map, as the directions module that the view uses to create JavaScript has no way to accept a pre-calculated route, and can only create new ones. I'm just wondering if it is indeed possible to create and show routes this way, and if not, why?
The directions manager in the Bing Maps JavaScript SDK does not support passing in a precalculated route. You will need to pass over all the route options and let the directions manager calculate the route.

Leaflet adding markers on map and data security

I'm looking into using Leaflet to make maps and place markers in an internal application (i.e. not a web-site, but a simple desktop application), but I'm wondering which data is sent and which is not. Do the following command send any data or is it only plotted locally?
marker = L.marker([51.5, -0.09]).addTo(mymap);
Needless to say, I want to keep my data confidential and not send it away over the web.
(If this is the case, then any recommendation on a good alternatives).
It's all local (I use leaflet offline all the time). If you want to check the source code for markers and look for yourself, feel free to check it out here
As an in-browser javascript library, I've never come across a situation where leaflet sent data. In fact, the only thing you really need an internet connection for in leaflet is to get map tiles/images.

Caching Google maps routes

I've got a geojson file with a bunch of points. I use Google Maps to get routing information between these points (using the JS API v3). Unfortunately I'm getting the OVER_QUERY_LIMIT error status back because I'm doing too many routing requests at a time.
For now I've solved it by delaying my routing requests. But that is not a long term solution. It takes too long to draw the full route now.
What I want to do is cache the routes. The only time I'd need to invalidate the cache is when the geojson file is updated (let's say this happens once a week maybe).
It's a static site. So all the logic is client side JavaScript. The site is hosted as a GitHub project page.
Any ideas on how I could implement the caching? Could Jekyll (github pages tool) help in any way? I don't know exactly what it does. Or some Travis-CI script?
EDIT: Just to clarify; It'd be enough to cache just the polyline and then draw that. I don't need the actual driving directions. I also don't need to be able to edit the route by drag-n-drop.
You can choose to use cookies for client side data storage.
Store a date and the polypoints array in cookie and when no cookie/ out of date, make a request, otherwise just draw poly on the map.
I would say use php or something and store it on server, I know You don't want that.
What I ended up doing was to write a node.js script that generates a polyline file with the route. Then I just draw that polyline on the map. The route changes seldom enough that I don't mind that it's a manual step.
It's been a year, but I think this is the final version of the script that generates the polyline: https://github.com/Tobbe/highpointing/blob/master/lib/route_creator.js

How can I create a custom, shareable and colaborative map?

My situation is this: I have my API code and my website running, then I can load a map, access it from JavaScript and create overlays or functions, but I'm trying to store (save) these custom markers (overlays obtained from script) in a map in a permanent way, but I'm unable to do it as every time I refresh my webpage the markers (and all overlays) disappear and the map reloads without any overlays or any markers, and I don't know how can I solve this.
How can I create a custom, shareable and colaborative map?
Note that I can get a map and create temporary overlays through a JavaScript in my website, but I can't save (store) these overlays or create permanent markers.
Is it possible do it through JavaScript Code (API v3) direct in my website?
Do I need to purchase a Map Engine (for Business) license?
I would not like to use my own database, but use something based on a Google Maps, like a layer e.g., where I could store markers. Is there any way? Google Maps Engine does this?
I've been reading something about "layerID" and "MapID" from Maps Engine (for business) where I think it would be possible to store custom markers (and drawings) in a custom layer direct in google maps Engine. But I didn't find anything about this in internet and I don't have access to Maps Engine (for business) to try.
Look in the articles section of the documentation
These two articles will allow you to collect data from InfoWindows, and display data from the database on a map (make the data persistent):
Using PHP/MySQL with Google Maps
Shows how to use PHP/MySQL and the Google Maps API v3 to create a map that polls data from a database and shows as markers.
From Info Windows to a Database: Saving User-Added Form Data
Shows how to prompt users to fill out information in an infowindow, and then save that information back into a database.
Extend to save and retrieve data from the Drawing Manager if you need to save other geographic data besides markers.

API access to a manually-created Google Map

I have a number of public custom Google Maps created via http://maps.google.com/ - obviously associated with my google account.
Can I access these maps via the Google Maps javascript api? The api doesn't appear to work with the manually created maps located on maps.google.com from what I can tell?
And if not, is there another way to store overlay data (markers, etc) that the javascript api can grab and load into the map on the client's browser?
Am thinking a service like dabbleDB, except that I don't think they offer write access via javascript (this would be necessary for the user adding markers to the map, for example)
Obviously I could create a db layer on my server, but am looking for a 'cloud' solution that removes the strain from my databases!!
Digging into the no longer available Google Maps Data API lead me to that powerful and comprehensive Google Fusion where you can search nearest places within your own dataset such as find features within a radius. Enjoy !
See if GData Maps API is what you need.

Categories

Resources