修正地球自适应问题。修正地图搜索卡死问题。

This commit is contained in:
suntao committed 2021-04-28 15:30:38 +08:00
1 parent c8111d7db3
commit 3b63dec2e1
16 files changed
+725 -1163

No files matched your search

@@ -3,12 +3,12 @@ using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class LoadingPf : MonoBehaviour
public class LoadingPf : PFUIPanel
{
List<Sprite> sprites;
Image image;
private void Start()
protected override void Start()
{
sprites = new List<Sprite>();
for (int i = 1; i < 80; i++)
@@ -19,11 +19,14 @@ public class LoadingPf : MonoBehaviour
}
int index = 0;
float time = 0;
public void Initial()
public override void Show()
{
base.Show();
index = 0;
time = 0;
}
void Update()
{
time += Time.deltaTime;
@@ -99,7 +99,16 @@ public class BigMapController : PFUIPanel
content = panel.Find("Scroll View").Find("Viewport").Find("Content").gameObject;
var input = panel.Find("InputField");
base.SetRounded(input, 20f);
input.GetComponent<InputField>().onEndEdit.AddListener((text) =>
{
if (Input.GetKeyDown(KeyCode.Return))
{
this.Search(null);
}
});
keyword = input.Find("Text").GetComponent<Text>();
var searchBtn = input.Find("Search").gameObject;
UIManager.AddEvent(searchBtn, EventTriggerType.PointerClick, Search);
@@ -141,22 +150,27 @@ public class BigMapController : PFUIPanel
}
private void Search(BaseEventData e)
private async void Search(BaseEventData e)
{
if (string.IsNullOrWhiteSpace(keyword.text))
{
//yield return null;
return;
}
Debug.Log(keyword.text);
//UIManager.ShowLoadingDialogBox();
//Utils.showLoading(this.gameObject);
var infoStr = mapboxApi.GetAddressInfo(keyword.text);
//Debug.Log(info);
UIManager.ShowLoadingDialogBox();
var infoStr = await mapboxApi.GetAddressInfo(keyword.text);
//Debug.Log(infoStr);
var info = Newtonsoft.Json.Linq.JObject.Parse(infoStr);
var center = (info["features"] as JArray).First()["center"];
mapManager.UpdateMap(new Vector2d(Convert.ToDouble(center[1]), Convert.ToDouble(center[0])));
//mapManager.SetCenterLatitudeLongitude(new Vector2d(31.325053, 120.623564));
//mapManager.UpdateMap(new Vector2d(31.325053, 120.623564));
UIManager.HideLoadingDialogBox();
}
private void MapManager_OnInitialized()
@@ -22,11 +22,21 @@ public class EarthController : PFUIPanel
private GameObject hotPanel;
private GameObject content;
private Object itemObject;
Transform rootPanel;
Canvas canvas;
float time = 0f;
bool showSummary = false;
Vector2 latlonCenter;
protected override void Awake()
{
base.Awake();
mapApi = new MapApi();
canvas = this.transform.Find("Canvas").GetComponent<Canvas>();
canvas.worldCamera = Camera.main;
rootPanel = this.transform.Find("Canvas").Find("Panel");
map = WorldMapGlobe.instance;
map.showProvinces = true;
map.showCities = true;
@@ -46,7 +56,7 @@ public class EarthController : PFUIPanel
protected override void Start()
{
itemObject = Resources.Load("UI/Prefab/BigMap/Item");
var rootPanel = this.transform.Find("Canvas").Find("Panel");
var panel = rootPanel.Find("Panel");
SetRounded(panel, 60);
@@ -111,11 +121,14 @@ public class EarthController : PFUIPanel
Province.text = province.name;
ShowSummary(province.latlonCenter);
latlonCenter = province.latlonCenter;
time = 0f;
showSummary = true;
//ShowSummary(province.latlonCenter);
};
map.OnProvinceExit += (int provinceIndex, int regionIndex) =>
{
showSummary = false;
};
map.OnProvinceClick += (int provinceIndex, int regionIndex) =>
{
@@ -188,7 +201,7 @@ public class EarthController : PFUIPanel
private void Map_OnClick(Vector3 sphereLocation, int mouseButtonIndex)
{
Debug.Log("click");
//Debug.Log("click");
Vector2 latLon = Conversion.GetLatLonFromSpherePoint(sphereLocation);
Debug.Log("Clicked on Latitude: " + latLon.x + ", Longitude: " + latLon.y);
@@ -211,8 +224,18 @@ public class EarthController : PFUIPanel
void Update()
{
//var zoom = map.GetZoomLevel();
//Debug.Log(zoom);
if (showSummary)
{
time += Time.deltaTime;
if (time >= 0.2)
{
ShowSummary(latlonCenter);
showSummary = false;
}
}
//Debug.Log(showSummary + "," + time);
}
public void Show(double lat, double lon)