context: using UnityEngine;
  using System.Collections;
  using System.Runtime.Serialization;
  
  /**
   *
   * @Class: GoogleMap
   * @Summary: Simple interface for generating a valid http query.
   * 		This class is not intended to be attached to an object directly.
   *
   *	API REFERENCE:
   *		https://developers.google.com/maps/documentation/staticmaps/?csw=1
   *
   * 		Based off an open source unity asset: 
   * 		 https://www.assetstore.unity3d.com/#/content/3573 
   * 		by 'Different Methods'
   * 		 https://www.assetstore.unity3d.com/#/publisher/147
   * 
   * Really rough ranges for GPS coord:
   * 
   * top left  -32.06458, 115.82777
  	top right -32.06458, 115.84225
  	middle    -32.06691, 115.834507
  	bottom right -32.07236, 115.84290
  	bottom left  -32.07392, 115.82646
   * 
   * 
   * @Author: Michael J. Kiernan
   * @Group: Red Studio
   * @Project: Murdoch Navigate
   * @Date Created: 09/04/14.
   * 
   * @Version: 0.1.
   * 
   * 0.1 - Made functions more modular. 12/04/14.
   * 
   * 0.0 - Created class. 09/04/14.
   *
  */
  [ExecuteInEditMode]
  [System.Serializable]
  public class GoogleMap
  {
  
  	// api key
  	static private string m_keyLocation = "StaticMap/developer_key";
    [SerializeField]
  	static private string m_developerKey = "";
  
  	// query server
  	static private string m_queryServer = "http://maps.googleapis.com/maps/api/staticmap";
  
  	// generate query on construction if true
  	[SerializeField]
  	public bool m_queryOnStart { get; set; }
  	
  	// auto locate center if true
  	[SerializeField]
  	public bool m_autoLocateCenter { get; set; }
  	
  	// address name
  	[SerializeField]
  	public string m_address { get; set; }
  
  	[SerializeField]
  	public double m_latitude { get; set; }
  	
  	[SerializeField]
  	public double m_longitude { get; set; }
  	
  	// zoom
  	[SerializeField]
  	public int m_zoom {get; set; }
  	
  	// size/resolution (w x h = w x w / h x h)
  	[SerializeField]
  	public int m_size { get; set; }
  	
  	// scale
  	[SerializeField]
  	public int m_scale { get; set; }
  	
  	// query
  	[SerializeField]
  	public string m_query { get; private set; }
  	
  	// map type: google defined data type
  	[SerializeField]
  	public string m_mapType { get; set;	}
  
  	[SerializeField]
  	public bool m_doubleResolution { get; set; }
  
  	[SerializeField]
  	public GoogleMapMarker[] markers;
  
  	[SerializeField]
  	public GoogleMapPath[] paths;
  	
  	/**
       * @Function: GoogleMap() constructor.
       * 
       * @Summary: Initialises query variables.
       * Please refer to static maps API.
       * */
  	public GoogleMap()
  	{
  		m_query = "";
  		m_doubleResolution = true;
  		m_address = "";
  		m_latitude = 0d;
  		m_longitude = 0d;
  		m_mapType = "hybrid";
  		m_zoom = 16; // this is the zoom level that determines the zoom the texture is sent to
  		m_scale = 2; // 1, 2 are the only values
  		m_size = 640; // 640 max
  		m_queryOnStart = true;
  		m_autoLocateCenter = false;
  		
  		if (m_queryOnStart)
  		{
  			generateQuery ();
  		}
  
  		// populate the api key (keeping it out of vcontrol)
  		TextAsset bindata = Resources.Load("apiKey") as TextAsset;
          Debug.Log(bindata.text);
  		m_developerKey = bindata.text;
  	}
  
  	public GoogleMap(GoogleMap rhs)
  	{
  		if(rhs != null)
  		{
  			m_query = rhs.m_query;
  			m_doubleResolution = rhs.m_doubleResolution;
  			m_address = rhs.m_address;
  			m_latitude = rhs.m_latitude;
  			m_longitude = rhs.m_longitude;
  			m_mapType = rhs.m_mapType;
  			m_zoom = rhs.m_zoom; // this is the zoom level that determines the zoom the texture is sent to
  			m_scale = rhs.m_scale; // 1, 2 are the only values
  			m_size = rhs.m_size; // 640 max
  			m_queryOnStart = rhs.m_queryOnStart;
  			m_autoLocateCenter = rhs.m_autoLocateCenter;
  		}
  	}
  
  	/**
       * @Function: GoogleMap() constructor.
       * 
       * @Summary: Overloaded constructor to initialise query variables.
       * */
  	public GoogleMap(string query, bool doubleResolution, string address, 
  	                 float latitude, float longitude, string mapType, 
  	                 int zoom, int scale, int size, 
  	                 bool queryOnStart, bool autoLocateCenter)
  	{
  		m_query = query;
  		m_doubleResolution = doubleResolution;
  		m_address = address;
  		m_latitude = latitude;
  		m_longitude = longitude;
  		m_mapType = mapType;
  		m_zoom = zoom;
  		m_scale = scale;
  		m_size = size;
  		m_queryOnStart = queryOnStart;
  		m_autoLocateCenter = autoLocateCenter;
  		
  		if (m_queryOnStart) {
  			generateQuery ();
          }
      }
  
  	public void print()
  	{
  		Debug.Log("m_query: " + m_query);
  		Debug.Log("m_doubleResolution: " + m_doubleResolution);
  		Debug.Log("m_address: " + m_address);
  		Debug.Log("m_latitude: " + m_latitude);
  		Debug.Log("m_longitude: " + m_longitude);
  		Debug.Log("m_mapType: " + m_mapType);
  		Debug.Log("m_zoom : " + m_zoom);
  		Debug.Log("m_scale: " + m_scale);
  		Debug.Log("m_size: " + m_size);
  		Debug.Log("m_queryOnStart: " + m_queryOnStart);
  		Debug.Log("m_autoLocateCenter: " + m_autoLocateCenter);
  	}
  	
  	/**
       * @Function: generateQuery()
       * 
       * @Summary: Generate a HTTP query for google static maps server.
       * */
  	public void generateQuery()
  	{
  		var qs = m_queryServer;
  		
  		if (m_address != "")
  			qs += "?center=" + WWW.EscapeURL(m_address);
  		else 
  		{
  			qs += "?center=" + WWW.EscapeURL(string.Format("{0},{1}", m_latitude, m_longitude));
  		}
  		
  
gt: 		qs += "&zoom=" + m_zoom.ToString();