void Start() { GameObject canvas = GameObject.Instantiate(Resources.Load <GameObject>("Canvas")); if (canvas == null || !showCanvas) { return; } gridTran = canvas.GetComponentInChildren <GridLayoutGroup>().transform; scrollCircle = canvas.GetComponentInChildren <ScrollCircle>(); GameObject buttonProto = Resources.Load <GameObject>("Button"); PoiInfo poiInfo = PoiParseTool.GetPoiObject(); if (poiInfo != null && poiInfo.poiList != null) { foreach (var tempPoi in poiInfo.poiList) { string strLog = $"poiid = {tempPoi.poiId}, posx ={tempPoi.posX}, posy = {tempPoi.posY}, posz = {tempPoi.posZ}"; GameObject button = GameObject.Instantiate(buttonProto); button.GetComponentInChildren <Text>().text = tempPoi.poiId; button.transform.SetParent(gridTran); button.GetComponent <Button>().onClick.AddListener(() => { this.transform.position = new Vector3(tempPoi.posX, tempPoi.posY, tempPoi.posZ); this.transform.localRotation = Quaternion.identity; Debug.Log("onclick" + this.transform.position); }); } } if (scrollCircle != null) { scrollCircle._rotationAction += changeCameraAngle; scrollCircle._dragStateAction += dragState; } }
// 获取 poi public List <PoiInfo> GetPois() { List <PoiInfo> poiList = new List <PoiInfo>(); try { IList results = res["results"] as ArrayList; foreach (Dictionary <string, object> result in results) { PoiInfo poi = new PoiInfo(); poi.Name = result["name"].ToString(); Dictionary <string, object> location = result["location"] as Dictionary <string, object>; poi.Lat = Convert.ToSingle(location["lat"]); poi.Lng = Convert.ToSingle(location["lng"]); poi.Address = result["address"].ToString(); if (result.ContainsKey("telephone")) { poi.Telephone = result["telephone"].ToString(); } poi.Uid = result["uid"].ToString(); if (result.ContainsKey("detail_info")) { Dictionary <string, object> detailInfo = result["detail_info"] as Dictionary <string, object>; if (detailInfo.ContainsKey("type")) { poi.Type = detailInfo["type"].ToString(); } if (detailInfo.ContainsKey("tag")) { poi.Tag = detailInfo["tag"].ToString(); } if (detailInfo.ContainsKey("detail_url")) { poi.DetailUrl = detailInfo["detail_url"].ToString(); } if (detailInfo.ContainsKey("price")) { poi.Price = detailInfo["price"].ToString(); } if (detailInfo.ContainsKey("shop_hours")) { poi.ShopHours = detailInfo["shop_hours"].ToString(); } if (detailInfo.ContainsKey("overall_rating")) { poi.OverallRating = detailInfo["overall_rating"].ToString(); } if (detailInfo.ContainsKey("taste_rating")) { poi.TasteRating = detailInfo["taste_rating"].ToString(); } if (detailInfo.ContainsKey("service_rating")) { poi.ServiceRating = detailInfo["service_rating"].ToString(); } if (detailInfo.ContainsKey("environment_rating")) { poi.EnvironmentRating = detailInfo["environment_rating"].ToString(); } if (detailInfo.ContainsKey("facility_rating")) { poi.FacilityRating = detailInfo["facility_rating"].ToString(); } if (detailInfo.ContainsKey("hygiene_rating")) { poi.HygieneRating = detailInfo["hygiene_rating"].ToString(); } if (detailInfo.ContainsKey("technology_rating")) { poi.TechnologyRating = detailInfo["technology_rating"].ToString(); } if (detailInfo.ContainsKey("image_num")) { poi.ImageNum = detailInfo["image_num"].ToString(); } if (detailInfo.ContainsKey("groupon_num")) { poi.GrouponNum = detailInfo["groupon_num"].ToString(); } if (detailInfo.ContainsKey("discount_num")) { poi.DiscountNum = detailInfo["discount_num"].ToString(); } if (detailInfo.ContainsKey("comment_num")) { poi.CommentNum = detailInfo["comment_num"].ToString(); } if (detailInfo.ContainsKey("favorite_num")) { poi.FavoriteNum = detailInfo["favorite_num"].ToString(); } if (detailInfo.ContainsKey("checkin_num")) { poi.CheckinNum = detailInfo["checkin_num"].ToString(); } } poiList.Add(poi); } } catch (Exception ex) { logger.Error(ex.Message); return(null); // json 解析错误 } return(poiList); }
private static PoiInfo ParseJson(string poiJson) { PoiInfo poiInfo = JsonUtility.FromJson <PoiInfo>(poiJson); return(poiInfo); }
public static void AddBaiduContent(ISheet sheet, PoiInfo poi, int index) { IRow contentRow = sheet.CreateRow(index); contentRow.CreateCell(0).SetCellValue(index); contentRow.CreateCell(1).SetCellValue(poi.Name); contentRow.CreateCell(2).SetCellValue(poi.Lng); contentRow.CreateCell(3).SetCellValue(poi.Lat); contentRow.CreateCell(4).SetCellValue(poi.Address); if (poi.Telephone != null) { contentRow.CreateCell(5).SetCellValue(poi.Telephone); } if (poi.Type != null) { contentRow.CreateCell(6).SetCellValue(poi.Type); } if (poi.Tag != null) { contentRow.CreateCell(7).SetCellValue(poi.Tag); } if (poi.DetailUrl != null) { contentRow.CreateCell(8).SetCellValue(poi.DetailUrl); } if (poi.Price != null) { contentRow.CreateCell(9).SetCellValue(poi.Price); } if (poi.ShopHours != null) { contentRow.CreateCell(10).SetCellValue(poi.ShopHours); } if (poi.OverallRating != null) { contentRow.CreateCell(11).SetCellValue(poi.OverallRating); } if (poi.TasteRating != null) { contentRow.CreateCell(12).SetCellValue(poi.TasteRating); } if (poi.ServiceRating != null) { contentRow.CreateCell(13).SetCellValue(poi.ServiceRating); } if (poi.EnvironmentRating != null) { contentRow.CreateCell(14).SetCellValue(poi.EnvironmentRating); } if (poi.FacilityRating != null) { contentRow.CreateCell(15).SetCellValue(poi.FacilityRating); } if (poi.HygieneRating != null) { contentRow.CreateCell(16).SetCellValue(poi.HygieneRating); } if (poi.TechnologyRating != null) { contentRow.CreateCell(17).SetCellValue(poi.TechnologyRating); } if (poi.ImageNum != null) { contentRow.CreateCell(18).SetCellValue(poi.ImageNum); } if (poi.GrouponNum != null) { contentRow.CreateCell(19).SetCellValue(poi.GrouponNum); } if (poi.DiscountNum != null) { contentRow.CreateCell(20).SetCellValue(poi.DiscountNum); } if (poi.CommentNum != null) { contentRow.CreateCell(21).SetCellValue(poi.CommentNum); } if (poi.FavoriteNum != null) { contentRow.CreateCell(22).SetCellValue(poi.FavoriteNum); } if (poi.CheckinNum != null) { contentRow.CreateCell(23).SetCellValue(poi.CheckinNum); } }