public static string GetUrl(GoogleMapPath path) { var qs = ""; //if (!autoLocateCenter) { if (!string.IsNullOrEmpty(CenterLocation.Address)) { qs += "center=" + URL.Encode(CenterLocation.Address); } else { qs += "center=" + URL.Encode(string.Format("{0},{1}", CenterLocation.Latitude, CenterLocation.Longitude)); } qs += "&zoom=" + Zoom; } qs += "&size=" + URL.Encode(string.Format("{0}x{0}", Size)); //qs += "&scale=" + (doubleResolution ? "2" : "1"); qs += "&maptype=" + MapType.ToString().ToLower(); qs += "&format=png32"; //только его не размывает //var usingSensor = false; //qs += "&sensor=" + (usingSensor ? "true" : "false"); /* * foreach (var i in markers) * { * qs += "&markers=" + * string.Format("size:{0}|color:{1}|label:{2}", i.Size.ToString().ToLower(), i.Color, i.Label); * foreach (var loc in i.Locations) * { * if (loc.Address != "") * qs += "|" + URL.Encode(loc.Address); * else * qs += "|" + URL.Encode(string.Format("{0},{1}", loc.Latitude, loc.Longitude)); * } * } */ if (path != null) { qs += "&path=" + string.Format("weight:{0}|color:{1}", path.weight, "0xff0000ff"); if (path.fill) { qs += "|fillcolor:" + path.FillColor; } qs += "|enc:" + EncodePolyline.EncodeCoordinates(path.Locations); } qs += "&key=AIzaSyAzduON1ycPY7318RfjwIjI3vtnWN8xb_s"; return(Url + "?" + qs); }
public static GoogleMapPath GetPathFromString(string coords) { var p = new GoogleMapPath(); try { coords = coords.Trim(); if (coords[coords.Length - 1] == ';') { coords = coords.Remove(coords.Length - 1); } p.Color = GoogleMapColor.red; var locat = new List <GoogleMapLocation>(); foreach (var c in coords.Split(';')) { var l = new GoogleMapLocation(); try { l.Latitude = float.Parse(c.Split(',')[0]); l.Longitude = float.Parse(c.Split(',')[1]); locat.Add(l); } catch (Exception e) { Debug.Log(e.Message + "=" + c); throw; } } p.Locations = locat; } catch (Exception e) { Debug.Log(e.Message); throw; } return(p); }