예제 #1
0
    private IEnumerator Start()
    {
        while (!_locationController.isInitialized)
        {
            yield return(null);
        }

        CategoryType[] categoryTypes = getSavedCategoryTypes().ToArray();
        for (int i = 0; i < categoryTypes.Length; i++)
        {
            List <string> categories   = new List <string>();
            CategoryData  categoryData = CATEGORY_TYPES_TO_SEARCH_CATEGORIES[categoryTypes[i]];
            for (int j = 0; j < categoryData.Filters.Length; j++)
            {
                categories.Add(categoryData.Filters[j]);
            }

            string[] outFields =
            {
                "PlaceName",
                "Place_Addr",
                "City",
                "Region",
                "Location",
            };
            float longitude  = _locationController.getLongitude();
            float latitude   = _locationController.getLatitude();
            int   maxResults = AppConsts.DEFAULT_MAX_RESULTS;
            List <CandidateData> candidateData = ArcGSIRequestHelper.findAddressCandidates(categories.ToArray(), outFields, longitude, latitude, maxResults);

            Material candidateMaterial = GameObject.Instantiate(_candidatePrefab.meshRenderer.sharedMaterial);
            candidateMaterial.color = categoryData.Color;

            for (int j = 0; j < candidateData.Count; j++)
            {
                // Skip earth since yes, that's a data point
                if (candidateData[j].placeName.Equals("Earth"))
                {
                    continue;
                }

                CandidateController candidateInstance = GameObject.Instantiate(_candidatePrefab);
                candidateInstance.Initialize(candidateData[j]);
                candidateInstance.transform.position = new Vector3((candidateData[j].x - longitude) * AppConsts.MAP_SCALE_FACTOR, 0, (candidateData[j].z - latitude) * AppConsts.MAP_SCALE_FACTOR);

                candidateInstance.meshRenderer.sharedMaterial = candidateMaterial;

                _activeCandidates.Add(candidateInstance);
            }
        }
    }