Displaying Google Maps in Unity on mobile devices

13,560

Solution 1

You can use Unity's WWW.texture and Google's static maps API to render their map as a texture on a GameObject. For my example I used a plane, nothing fancy. The image URL I used in my example was taken directly from the Google API page. One note, you'll need to use your own API key, I've left that value blank. If you run my example without the API key, you'll get a 403 error.

using UnityEngine;
using System.Collections;

public class GoogleMaps : MonoBehaviour {

string exampleUrl = "http://maps.googleapis.com/maps/api/staticmap?center=Brooklyn+Bridge,"+
                    "New+York,NY&zoom=13&size=600x300&maptype=roadmap&markers=color:blue%7Clabel:S%7C40.702147,-74.015794"+
                    "&markers=color:green%7Clabel:G%7C40.711614,-74.012318"+
                    "&markers=color:red%7Ccolor:red%7Clabel:C%7C40.718217,-73.998284"+
                    "&sensor=false";
string key = "&key=YOUR_API_KEY"; //put your own API key here.

 IEnumerator Start() {
    WWW www = new WWW(exampleUrl+key);
    yield return www;
    renderer.material.mainTexture = www.texture;
}
}

Solution 2

Some time ago, I started to work on map based framework for unity3d: ActionStreetMap. The current version (0.7) supports the following features:

  • Rendering of different models (e.g. buildings, roads, parks, rivers,POI, etc.) using OpenStreetMap (OSM) data for given location on the fly by terrain tiling approach.
  • Offline and online modes.
  • Non-flat terrain with Data Elevation Model (SRTM) files.
  • Easy customization by mapcss-like files.
  • Modification of city environment (terrain craters, corrupt buildings, etc..).
  • Fast 2D overview mode for large area.
  • Targeting mobile (VR?) devices.

You can find web demo builds here.

Share:
13,560
The Coding Monk
Author by

The Coding Monk

Artificial Intelligence and Robotics student. Programmer, IT enthusiast, and many other things. Follow me on Twitter @TheCodingMonk

Updated on August 21, 2022

Comments

  • The Coding Monk
    The Coding Monk over 1 year

    Is there a way to display Google Maps (even other maps should be ok) in Unity 3D but on mobile devices (both Android and iOS)?

    Even paid plugins are ok.

  • sooon
    sooon almost 10 years
    This is rather interesting. However, what if we want to make a constant update like the real GPS? For example if we feed it Longtitude and Latitude.
  • ShawnFeatherly
    ShawnFeatherly almost 9 years
    If you'd like a map to move with GPS you'd need a "Slippy map". Here's one: github.com/jderrough/UnitySlippyMap