- Home /
embed google maps into unity 3d
Can I use www class or some other way to fetch and display google maps into unity?
hello all, what i recently found, when you use:
you get retrieval error, as it fails security restrictions. what is also known, .jpg, .png etc, types are allowed.
which lead me to succesfuly using:
adding "?a.jpg" does not spoil google maps query and bypasses unity player security :)
full example code, just attach jscript to plane :)
=====================================
pragma strict
var url = ""; var lat : float; var lon : float; var li : LocationInfo;
function Start () { li = new LocationInfo();
lat = li.latitude; lon = li.longitude;
var www : WWW = new WWW(url); yield www;
renderer.material.mainTexture=www.texture;
}
Answer by duck · Jun 11, 2010 at 10:11 AM
It is possible to fetch and display Google Maps into your own applications (it's not against the Terms Of Use, as SpikeX said), but you have to go about it in the proper way - i.e. sign up for a Maps API key, and abide by the strict terms and conditions which define what you can & can't do with the data they provide.
So - you can't just embed or "screen scrape" the google maps web page. :-)
As for whether it would be possible to create a working implementation of Maps in Unity, I'm not sure. I have a hunch that it might be technically possible, but it would be a very large undertaking.
An easier way (if you're targeting the webplayer) might be to use one of the existing implementations in Flash, and switch between flash & unity on your web page so that users use the Flash app to browse/select your map, and then you send image data to your Unity app via in-page-Javascript commands. (this is all possible!).
how do you switch between a webpage and your unity app on a mobile device?
It's worth mentioning that some of those terms of use by which you must abide are pretty restrictive.... including:
9.1.1a) Free Access (No Fees). Your $$anonymous$$aps API Implementation must be generally accessible to users without charge and must not require a fee-based subscription or other fee-based restricted access. This rule applies to Your Content and any other content in your $$anonymous$$aps API Implementation.
10.1.3a) No Unauthorized Copying, $$anonymous$$odification, Creation of Derivative Works, or Display of the Content. You must not copy, translate, modify, or create a derivative work (including creating or contributing to a database) of, or publicly display any Content or any part thereof except as explicitly permitted under these Terms. For example, the following are prohibited: (i) creating server-side modification of map tiles; (ii) stitching multiple static map images together to display a map that is larger than permitted in the $$anonymous$$aps APIs Documentation;
10.1.3b) You must not pre-fetch, cache, or store any Content.
10.2d) No Navigation, Autonomous Vehicle Control, or Enterprise Applications. You must not use the Service or Content with any products, systems, or applications ... synchronized to the position of a user's sensor-enabled device.
So, you can't charge for a game that uses Google $$anonymous$$aps, you can't alter the imagery at all to match the style of your game, you have to re-download all the map data from Google every time you play a game, and you can't use it for Augmented Reality apps that make use of a mobile devices' GPS/compass etc....
@duck Can i show complete google earth map on sphere? http://stackoverflow.com/questions/34017284/show-complete-interactive-google-map-on-sphere-globe
Answer by tokenshi · Jul 28, 2011 at 07:01 PM
Here's a simple implementation using Static Maps: 1) Create a plane, point the camera at it, add a light source
2) Add the following script to the plane
var url = ""; var lat : float; var lon : float; var li : LocationInfo;
function Start () { li = new LocationInfo();
lat = li.latitude; lon = li.longitude;
var www : WWW = new WWW(url); yield www;
renderer.material.mainTexture=www.texture;
}
You don't need the API key for it, and to my knowledge it doesn't violate ToS
unfortunately, unless you have a premier account, it is not allowed to use beyond the browser - for example, inside an app. decarta maps is an alternative though
i tried this and it work in the editor of unity but in android doesn't work, how i can make this work for android and ios?
just dont work at all.... unity needs google to add a crossdomain.xml. lol This is too bad. would have made unity a wonderfull thing for the web.
The free asset store package "Google $$anonymous$$aps for Unity" also uses staticmap. https://www.assetstore.unity3d.com/en/#!/content/3573 Works in Unity 4.6.5f1 using the fixes from "philipho"'s review of the package.
Answer by qJake · Jun 10, 2010 at 10:14 PM
No, this is not possible, and I wouldn't recommend it, as it's against the Google Maps Terms of Use.
it's not outright against the Terms Of Use to use Google maps in your own apps - but you have to sign up for a $$anonymous$$aps API key and go about it the proper wya - and there are strict terms and conditions about what you can & can't do.
Oh, I read somewhere else on here that this wasn't possible, and I wasn't sure about an API $$anonymous$$ey being used for inside a video game.
currently, maps api key is not necessary for google maps static. however, unless you have a premier account, usage is only allowed within browser
Answer by tarasfromlviv · Oct 28, 2018 at 07:02 PM
My plugin Google Maps View does exactly this: https://assetstore.unity.com/packages/tools/integration/google-maps-view-82542
Works on Android and on iOS. It is a native view so the performance is great. The only limitation is that you can't display Unity scene objects on top of it.