- Home /
WWW Request for image error, unsupported URL
Hello, I'm trying to download a Google Static Map image to my mobile app. This is working properly on Android and Windows, unfortunately I'm getting the unsupported URL error on iOS. Here is the code;
IEnumerator GetGoogleMapsImage()
{
WWW request = new WWW(WWW.EscapeURL("https://maps.googleapis.com/maps/api/staticmap?center=" + MapCenter.Latitude + "," + MapCenter.Longitude + "&zoom=15&size=1280x1280&maptype=hybrid&sensor=false&style=feature:all|element:labels|visibility:off&scale=4&key="+apikeyGoogle));
while (!request.isDone) {
Debug.Log ("Downloading");
yield return 0;
}
if (request.error != null) {
Debug.Log (request.error+": "+request.url);
}
if (request.isDone && notLoaded) {
Debug.Log ("IMAGE!");
Debug.Log (request.texture.height);
mapDownloadOriginal = request.texture;
Map.sprite = Sprite.Create (mapDownloadOriginal, new Rect (0, 0, mapDownloadOriginal.width, mapDownloadOriginal.height), new Vector2 (0.5f, 0.5f));
mapBounds = MercatorProjection.GetBounds (MapCenter, 15, 640, 640);
onePercentCoordinates = new Coordinates ();
onePercentCoordinates.Latitude = (mapBounds.NorthEast.Latitude - mapBounds.SouthWest.Latitude) / 100;
onePercentCoordinates.Longitude = (mapBounds.NorthEast.Longitude - mapBounds.SouthWest.Longitude) / 100;
StartCoroutine (PlaceMarker ());
StartCoroutine (PlaceMarkerBlue ());
notLoaded = false;
}
yield return 0;
}
Does somebody know any solution? Or maybe an alternative to get the image in my app?
Answer by elenzil · Oct 19, 2016 at 05:43 PM
you might try using the newer UnityWebRequest framework instead of WWW. it's significantly more modern.
but iOS might still complain.
what's the exact results of EscapeURL ? what happens if you try to enter that URL right into safari ?
Thanks a lot mate, it works perfectly with the UnityWebRequest framework. Barely had to make any changes either. Cheers!
Hi Leniaal/elenzil - Am facing a similar issue with WWW, in iOS. I tried UnityWebRequest too. It says req.isDone as true, but when I try to use the texture, it gives me the error - InvalidOperationException. - which comes when Unity was unable to decode the downloaded data, or has not yet finished decompressing/decoding the downloaded data.
Here is the link to the post, where I posted this query. http://answers.unity3d.com/questions/1348908/download-texture-in-unity3d-not-working-1.html
Would you $$anonymous$$d sharing a sample code on how you got it working with UnityWebRequest? Thanks.
Appreciate your help.
It works for me too. In iOS WWW does not work for some URL's for some reason (when having Cyrillic characters or something. $$anonymous$$igrating to UnityWebRequest solved the problem
Even if UnityWebRequest works fine, have you guys found out a solution for WWW? Or at least 'why' it does complain? I am using $$anonymous$$APNAV Plugin and it is completely shut down at the time.Even tried to configure xCodes NSAppTransportSecurity The $$anonymous$$aps never load with the WWW. I am wondering if the issue is cleared now. Got the same problem with some more URLs in the iOS build while others ins$$anonymous$$d work fine. Cheers
i found something interesting recently if you do this
print ("i recieved: "+responce.text);
// if there is a png or jpg in there somewhere it will tell you in the console
it also shows if there is any B.S. before the image so you can grab the bytes you need and use texture.LoadImage
Your answer
Follow this Question
Related Questions
is it possible to get the url from a webpage? 1 Answer
AssetBundle won't download on iPad 0 Answers
Video 'not supported' on iPad 1 Answer
Google VR for IOS error 0 Answers
WWW problem : URL with blank symbol not functional on iOS 1 Answer