Search Unity

Google Maps API V3

Discussion in 'Scripting' started by Freakalot, Dec 2, 2011.

  1. Freakalot

    Freakalot

    Joined:
    Nov 30, 2011
    Posts:
    2
    Hello!

    Does anyone know if its possible and how to use an external API
    such as Google Maps Javascript API V3?

    greetings
    Daniel
     
  2. JayShades

    JayShades

    Joined:
    Mar 13, 2011
    Posts:
    125
    Hey Freakalot, I've been trying to figure out the same for a few days now with no luck of course.

    Does anyone know any way that we could use Google Maps Javascript API V 3 with Unity????
     
  3. All_American

    All_American

    Joined:
    Oct 14, 2011
    Posts:
    1,528
    I am sure there is a way to use it... but it isn't free....completely.
     
  4. Phil W

    Phil W

    Joined:
    Dec 21, 2008
    Posts:
    231
    The answer is yes, you can, but the difficulty (and cost) vary on what you want to do.

    You can get (free) static maps from a simple WWW request using the Static Maps API:
    https://developers.google.com/maps/documentation/staticmaps/

    There are Javascript and Flash versions of the dynamic API (what you're used to seeing at maps.google.com), but this is now a pay-for-usage API, and wouldn't be trivial (i.e. it would hard) to implement into Unity, as you will most likely have to go through a proxy, that is set up a go-between web page/web application through which your Unity app accesses the service.

    If all you need is maps then I'd suggest looking at OpenStreetMap. It's not only free, but it also lets you cache map tiles locally.

    There's an old (2009) entry in the wiki on OPM...it may be out of date, but it's a starting point.
    http://www.unifycommunity.com/wiki/index.php?title=OpenStreetMap_for_unity_iPhone


    Edit:
    There's a code snippet for grabbing and applying a Static Map to a texture in Unty Answers; see the second response down (by Tokenshi):
    http://answers.unity3d.com/questions/19263/embed-google-maps-into-unity-3d.html

    (p.s. you can find all of this out pretty easily using Google!)
     
    Last edited: Mar 17, 2012
  5. JayShades

    JayShades

    Joined:
    Mar 13, 2011
    Posts:
    125
    Phil, thanks, I actually did find all that out more but as obviously as you can see, none of those show how I can use the Google Javascript API V3 on Unity.

    I did try countless times but obviously I had no idea what I was doing so it wasn't working anyways.

    And yes right now I'm using the Google Static map it works fine but I'd like it to have better functionality I'm quite sure that this could be achieved by using the full map with the API if I just knew a way how :)
     
  6. Tseng

    Tseng

    Joined:
    Nov 29, 2010
    Posts:
    1,217
    Depends on what you want to do.

    Is it an Webplayer application? You can use Application.ExternalEval and ExternalCall to communicate with the DOM tree/Website outside of the player.

    Of course you have to embedd your Google Maps API JS scripts into the website where your webplayer is placed. But you can not implement the Map itself into unity (static image being the only exception, which can be downloaded with the required HTTP GET call, for that you don't need the JS anyways, just use the WWW class for it)
     
  7. JayShades

    JayShades

    Joined:
    Mar 13, 2011
    Posts:
    125
    Tseng, it will be an Android/iPhone App actually.

    But yeah I did actually try embedding it to my site accessing it from there to create a static image but then again that's no use since it's just like using the Static Map that I already have in place right? Unless it can do more then that'll be brilliant but I honestly don't know because it didn't really work properly so I didn't really bother after a while.
     
  8. darkmax

    darkmax

    Joined:
    Feb 21, 2012
    Posts:
    83
    i'm interested too, in how to use the google maps api, i tried static maps, but i need a map more dinamyc.
     
  9. Slayerkris

    Slayerkris

    Joined:
    Jan 8, 2013
    Posts:
    8
    Last edited: Sep 5, 2013
  10. 8volution

    8volution

    Joined:
    Nov 14, 2012
    Posts:
    88
    MobinYaqoob likes this.
  11. MobinYaqoob

    MobinYaqoob

    Joined:
    Jun 26, 2014
    Posts:
    12
    I'm trying to change the url of MAPQuest to Google Map how can i ??
    In MAPNAV.js script what is the url when i trying to implement Google Maps
    ????????????????????????