- Home /
Static Map On a Plane
Hi so I have a OpenStreet Static Map for a specific location(longitude & latitude using the mobile device's GPS) with a specific zoom level embedded on to a plane in Unity as a texture.
The plane is at (0,0,0) & is 512 x 512 & the map is 512 x 512 as well. The embedding part works perfect.
Now what I want to do is to display the location of a user using the GPS.
The center of the map will be the users location since to load the map the users location is used earlier.
But unfortunately this isn't working proper, the position marker that is displayed on the map when I do this is way out of place of the center of the map.
The code that I'm using is:
var lat: float = 0.0; var lon: float = 0.0;
var currentPosition: GUITexture;
function Start() {
lat = 43.479615; //iPhoneInput.lastLocation.latitude; //The values are for testing in Unity, comment them & un-comment the variables for it to work with GPS lon = -80.575624 //iPhoneInput.lastLocation.longitude;
url = "http://staticmap.openstreetmap.de/staticmap.php?center="+lat+","+lon+"&zoom=8&size=512x512";
var www : WWW = new WWW(url); //Load the static map URL yield www; //Wait for the map to load
renderer.material.mainTexture=www.texture; //Set the downloaded texture into the plane
}
function Update () {
pixelX = (((lon + 180) / 360) (2^8) 256); pixelY = (((Mathf.Atan(Mathf.Sin(Mathf.Deg2Rad -lat) / Mathf.PI)) + 1) ((2^(8-1))));
currentPosition.pixelInset = Rect(pixelX, pixelY, 20, 10);
}
Any help is really appreciated!! Thanks! Cheers! Jay!
Your answer
Follow this Question
Related Questions
Loading scene in background? 1 Answer
Writing javascript for web and android 1 Answer
Loading from multiple files? 2 Answers
Collision not working. 1 Answer