google map V3 - private kml feed - google-maps

I am trying to switch from virtual (VE) earth to google map (GM).
It is pretty easy to overlay a georss feed over a map in VE as well as in GM:
var georssLayer = new google.maps.KmlLayer('www.bla.com/kmls/k1');
georssLayer.setMap(map);
Unfortunately, google requires the 'kml address' to be public. What can I do to achieve the same functionality if my address is not public (e.g. when the user has to login before [s]he can enjoy the map)?
Thanks.
Christian

I've thought about this issue before and this is the solution I've come up with (although I haven't implemented it yet).
The server code that generates the html page in which the map is embedded should generate a temporary token that is tied to the current user in the database.
Make the KML address public, but pass the temporary token to it as a query parameter
Include logic in the KML server code that checks the passed token to be sure it is valid
The token should only be valid for a limited time.
This solution will be slightly less secure than full id/pw authentication on the KML resource. But by using a short lived token, it may be good enough, depending on your requirements.

Related

Is there a platform agnostic HTML5 map service?

I have a Blazor combined client/server side app that uses HTML5 geolocation to return the user device latitude/longitude. I'd like to be able to provide the general "area" the user is in - a bit of a confirmation to the user the thing is working; and someday potentially enable the user to get lat/long for other locations as well. I have not been able to find a native HTML5 map service to go along with its geolocation capabilities, and in fact nearly every search leads to how to connect to Google Maps. I'm using Blazor, though, because I want the app to run and function on essentially every browser, so want to avoid Google Maps or Apple Maps, etc. I also checked quick on GitHub for potential API solutions but didn't see any. Ideas? Thanks!

How to track multiple vehicles with Maps API

I'm working on new application in my workplace as described below:
We have tens trucks working for us. I've installed a GPS module on each of them to track their position and store their coordinates in a database.
I need to see their movements in real time on a map (Google Maps, or Bing Maps) but I don't know how to do this.
I don't want code or snippets, I prefer Guidelines and API Docs or framework to build it!
If you have any question ask without problem! Thanks guys
Since you have the data in a database, the first step would be to expose that data to your app. There are a couple of different ways to do this depending on the type of app you want to create, however the most universal solution would be to create a web service that any of your apps can connect to. Here are a couple of good blog post on how to create spatial web services.
http://blogs.bing.com/maps/2013/07/31/how-to-create-a-spatial-web-service-that-connects-a-database-to-bing-maps-using-ef5
http://blogs.bing.com/maps/2013/08/05/advance-spatial-queries-using-entity-framework-5
Once you have a web service you can then create the app that will display the truck locations. You have a lot of options here; web, mobile, desktop (WPF, Windows app), cross platform. Web apps tend to be the most common as they can be accessed from the most locations. Connecting to a REST service from JavaScript is fairly easy. There is a number of different ways to load in real time data. The easiest is to use a timer that calls your web service regularly and grabs all truck locations. A slightly more complex option, but more efficient is to timestamp the last update of each location and then keep track of the last timestamp used to request an update. By doing this you can limit your request to only retrieve updates that have occurred since the last request. This would significantly reduce your bandwidth and make your app faster. Displaying the actual truck location on a map is easy. Your web service will return the location information, likely as either two number properties (i.e. latitude/longitude) or as a well known text string (simply parse this as shown in the previous blog posts). If using Bing Maps and you have two number properties, you can create a pushpin and add it to the map like this:
var loc = new Microsoft.Maps.Location(latitude,longitude);
var pin = new Microsoft.Maps.Pushpin(loc);
map.entities.push(loc);
Here are some useful resources around developing with Bing Maps:
https://www.bingmapsportal.com/ISDK/AjaxV7
https://msdn.microsoft.com/en-us/library/dd877180.aspx
Note, if you use Bing or Google maps (or just about any other major mapping platform), they require all asset tracking applications to have a license to use the maps. If you use Bing Maps, you can find details on licensing here: https://www.microsoft.com/maps/licensing/licensing.aspx#mainTab4

Embed a map from Google Maps Engine

A friend of mine has a Google Maps Engine account where he loads up map data which he want's to share with users. These maps are private (ie you need to log in to view them). I've made a system using PHP where people can login to my friends website and I want them to be able to view these maps embedded in his website.
In the Google Maps Engine (GME) interface each map has an 'API ID' and 'Layer names/keys'.
I also have a an API Project with an API Key, client ID, secret etc. Using my API Project I've been able to get an Access token and a Refresh token for my email address which is in the "viewable by" section of the GME interface.
My goal is that I can log onto my friend's website then, using server side PHP, use the refresh token which is now stored in a database, get an access token and echo the content part of his page with the map inside it.
This is what I want to do https://developers.google.com/maps/documentation/javascript/examples/mapsenginelayer-noauth-layerkey
But with Authentication.
I figured it out, in case anyone else has the same question you just need to add
accessToken: 'the_access_token',
In the list of Maps Engine Layer options. I fount the answer here: https://developers.google.com/maps/documentation/javascript/3.exp/reference#MapsEngineLayerOptions

how to integrate google latitude into a google map

I am setting up a website that shows a Google map and the location of various Google Latitude users on that map via markers.
Thing is, I can't find the exact code to do that. I have trawled through the Google API docs which are extensive but lacking in examples, actual examples of how a finished page might look.
So, I have my Google Map in place and I have registered an account on the Google API and set up OAUTH2 (got my clientID etc.) but I am stuck as to what to do next.
Any suggestions much appreciated.
The Latitude API documentation will tell you all the specific things it can do. It won't do general things for you like "put markers on a Google map"- it is meant to be used rather separately from Maps API. Your application will have to get Latitude oauth authorization for each of the users and use access tokens to request their locations. Only then will you start using Maps API to plot markers of those locations.
It sounds like you have no prior knowledge of any particular framework, so I'll outline how I would do it with Rails, which I believe to be easiest:
Build Omniauth into a new application, so that the user can sign in with Google. There are tutorials to assist you. The sign-in will result in an access token being stored in your database.
Add the latitude 'scope' to your omniauth implementation. The scope can be found in the latitude documentation, and the syntax to add it is found in the omniauth documentation.
For security reasons peculiar to latitude, you'll have to store the 'refresh token' that's supplied only on the first google sign-in for each user and exchange it hourly for a new access token as explained in the google oauth documentation.
Once you have a valid access token for each user at all times, you can use a library such as HTTParty to complete the GET described in the latitude documentation and retrieve a location.
Build a Google Map into a rails view as described in the Maps API documentation. In the controller action that processes that view, you can pass in the user locations for use as markers.
Good luck.

For Developing Location based reminder mobile app, which one is good..... Google Maps or Nokia maps

I am developing GPS based Location reminder in j2me. I am little bit confuse to which maps i use??.....Google maps & Nokia maps. Which one allows me good working... The working of my app are as follows :-
-User will provide a string to app to search a place of his/her desire.
-Then according to given string app will show a place on map by pointing marker on map.
-User can save that place or he/she can select a near by place rather than searched place by clicking on map or any other way.
-app will save that searched place coordinates & remind when it reached to near that place.
-When app remind to user about already stored place... that place should show on map by pointing an marker along with the how far he is from his destination.
The real choice here lies in whether to use a RESTful API like the Google Static Maps (or Nokia's RESTful Maps) or to use a native Java ME mapping library plugin such as the Nokia Maps API for Java ME. The latter has several major advantages:
Static mapping services such as the Google Static Maps API or Nokia's
RESTful Map API do not cache or tile the images when requested,
therefore each request involves a round trip to the server. If the
map on a mobile application needs to be refreshed at any time, using
a caching library will result in a reduction in network traffic after
around three maps have been displayed. An explanation of this can be
found here
As the name implies, Google's Static Maps API can only retrieve over
http static images for a requested coordinate point, image size,
image type and zoom level. Newer libraries offer additional
functionality out of the box offering dynamic Map content and touch
support, where the user can move around his/her current position,
zoom in, zoom out, modify the view mode to satellite or translate an
address to a coordinate point and show that on the map, among others.
This abstraction of the underlying functionality is hidden from the
developer so much less coding is needed in order to achieve the same
result .
Terms and Conditions for Nokia Maps are easier to fulfil than
Google - No legal restrictions of using the API outside a web browser
application or need to provide a link to the native Google Maps App
(if there is one), or to Google Maps (if there isn't one).
Nokia currently offer higher free daily request limits. Nokia Maps
API for Java ME supports up to 50,000 render requests per day and per
unique IP address (as of January 2012), for Nokia Developer
registered users (free of charge) while the limit for Google's Static
Maps API is currently 1000 unique (different) image requests per
viewer per day.
A couple of years ago there wouldn't be a choice, only RESTful solutions existed, but these days I would say a static http solution should only be used if you want a simple single image
As an abstraction of the underlying services, there are already a full set of examples to cover most of your use cases:
-User will provide a string to app to search a place of his/her desire.
-Then according to given string app will show a place on map by pointing marker on map.
http://www.developer.nokia.com/Commu...PI_for_Java_ME
-User can save that place or he/she can select a near by place rather than searched place by clicking on map or any other way.
Maybe you need to use a draggable marker:
http://www.developer.nokia.com/Devel...ples/#standard
Or react to the touch and find a Geocoordinate:
http://www.developer.nokia.com/Commu...PI_for_Java_ME
-app will save that searched place coordinates & remind when it reached to near that place.
This is known as geofencing and is covered by the Location API:
- http://www.developer.nokia.com/Resou...ty-events.html
-When app remind to user about already stored place... that place should show on map by pointing an marker along with the how far he is
from his destination.
Showing a Map with a Marker
http://www.developer.nokia.com/Devel...ples/#standard
For distance calculations, I guess you'd be after the ROUTING example
http://www.developer.nokia.com/Devel...mples/#routing
http://www.developer.nokia.com/Commu...g_with_Java_ME
Now you could re-write and all these services from scratch using RESTful APIs (and then go about debugging your code) , but I'm sure you'll agree it would be much easier to use an existing, working and tested framework for the low level plumbing and then just write your code on top using the services.
It is possible to encapsulate RESTful service in Java ME. As an example, added below is a screenshot from an app encapsulating the suggestion service
It is just a lot easier when someone else has already done this work for you and placed it in a library.