0

I'm making a mobile app on Unity, I know that to zoom into the map I need to calculate that new location using the mouse's coordinates, and then update the lat and lon on that point.

I have no idea how to do this. Well I do, I think but it's not working.

    using System.Collections;
    using UnityEngine;
    using UnityEngine.UI;

  public class GoogleAPI : MonoBehaviour
 {

   public string url;
public RawImage img;
public float lon;
public float lat;
public int zoom;
public int mapHeight;
public int mapWidth;
public int scale;
LocationInfo li;
public enum mapType { roadMap, satelite, hybrid, terrain };
public mapType mapSelected;

private IEnumerator Map()
{


    url = "https://maps.googleapis.com/maps/api/staticmap?center=" + lat + "," + lon +
        "&zoom=" + zoom + "&size=" + mapHeight + "x" + mapWidth + "&Scale=" + scale
        + "&maptype=" + mapSelected +
        "&markers=color:blue%7Clabel:S%7C40.702147,-74.015794&markers=color:green%7Clabel:G%7C40.711614," +
        "-74.012318&markers=color:red%7Clabel:C%7C40.718217,-73.998284&key=AIzaSyDh1_nS-l7nWOFWvt0Gg9-9dY_11qWzK_Q";
    WWW www = new WWW(url);
    yield return www;
    img.texture = www.texture;
    img.SetNativeSize();

}



private void Start()
{
    img = gameObject.GetComponent<RawImage>();
    StartCoroutine(Map());
    lat = Input.mousePosition.x;
    lon = Input.mousePosition.y;
    Debug.Log(lat + "\n" + lon);
}


public void ZoomUp_Click()
{
    zoom++;
}

public void ZoomDown()
{
    zoom--;
}
}

Obviously, it doesn't work. Am I on the right track with Input.mousePosition.x/y? Also I have 2 buttons on the map, up and down with the idea of zooming up and down 1 if the button is clicked. Again, am I close?

Thanks!

  • 1
    Possible duplicate of [Adding GoogleMaps to unity5](https://stackoverflow.com/questions/49490672/adding-googlemaps-to-unity5) – AresCaelum Mar 26 '18 at 21:56
  • Flagged as duplicate as this is the same thing you are still trying to figure out how to zoom in on the mouse's position. – AresCaelum Mar 26 '18 at 21:57
  • Well can you help a brother and tell me if I'm on the right track? –  Mar 26 '18 at 22:29

0 Answers0