private void OnMapClick() { control.GetCoords(out targetLng, out targetLat); if (targetMarker == null) { targetMarker = OnlineMapsMarker3DManager.CreateItem(targetLng, targetLat, targetPrefab); targetMarker.scale = targetScale; } else { targetMarker.SetPosition(targetLng, targetLat); } double tx1, ty1, tx2, ty2; map.projection.CoordinatesToTile(lng, lat, map.zoom, out tx1, out ty1); map.projection.CoordinatesToTile(targetLng, targetLat, map.zoom, out tx2, out ty2); rotation = (float)OnlineMapsUtils.Angle2D(tx1, ty1, tx2, ty2) - 90; if (!OnlineMapsKeyManager.hasGoogleMaps) { Debug.LogWarning("Please enter Map / Key Manager / Google Maps"); return; } OnlineMapsGoogleDirections request = new OnlineMapsGoogleDirections(OnlineMapsKeyManager.GoogleMaps(), new Vector2((float)lng, (float)lat), control.GetCoords()); request.OnComplete += OnRequestComplete; request.Send(); }
private void OnMapClick() { control.GetCoords(out targetLng, out targetLat); if (targetMarker == null) { targetMarker = OnlineMapsMarker3DManager.CreateItem(targetLng, targetLat, targetPrefab); targetMarker.scale = targetScale; } else { targetMarker.SetPosition(targetLng, targetLat); } double tx1, ty1, tx2, ty2; map.projection.CoordinatesToTile(lng, lat, map.zoom, out tx1, out ty1); map.projection.CoordinatesToTile(targetLng, targetLat, map.zoom, out tx2, out ty2); rotation = (float)OnlineMapsUtils.Angle2D(tx1, ty1, tx2, ty2) - 90; hasTargetPoint = true; if (lineRenderer == null) { GameObject go = new GameObject("LineRenderer"); go.transform.SetParent(transform, false); lineRenderer = go.AddComponent <LineRenderer>(); lineRenderer.material = lineRendererMaterial; #if UNITY_2017_3_OR_NEWER lineRenderer.positionCount = 2; lineRenderer.widthCurve = AnimationCurve.Constant(0, 1, 10); #elif UNITY_2017_1_OR_NEWER lineRenderer.positionCount = 2; lineRenderer.widthCurve = AnimationCurve.Linear(0, 10, 1, 10); #else lineRenderer.SetVertexCount(2); lineRenderer.SetWidth(10, 10); #endif } else { lineRenderer.enabled = true; } Vector3 p1 = control.GetWorldPosition(lng, lat); lineRenderer.SetPosition(0, p1); lineRenderer.SetPosition(1, p1); lineRendererProgress = 0; }