Exemplo n.º 1
0
        /// <summary>Periodically remove unneeded areas of the map.</summary>
        private IEnumerator UnloadUnseen()
        {
            while (true)
            {
                if (baseMapLoader != null && baseMapLoader.IsInitialized && NeedsUnloading)
                {
                    // Unload map regions that are not in viewport, and are outside a radius around the
                    // camera. This is to avoid unloading geometry that may be reloaded again very shortly (as
                    // it is right on the edge of the view).
                    mapsService.MakeMapLoadRegion()
                    .AddCircle(Camera.main.transform.position, baseMapLoader.MaxDistance)
                    .UnloadOutside();

                    if (UnloadedEvent != null)
                    {
                        UnloadedEvent.Invoke(Camera.main.transform.position, baseMapLoader.MaxDistance);
                    }

                    // Reset unload flag to prevent unnecessary calls each interval.
                    NeedsUnloading = false;
                }

                // Wait for a preset interval before seeing if new geometry needs to be unloaded.
                yield return(new WaitForSeconds(UnloadUnseenDelay));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Starts the loading of a Map Region defined by the viewport located at MaxDistance from the
        /// main Camera.
        /// </summary>
        public virtual void LoadMap()
        {
            if (MapsService == null || RenderingStyles == null || !IsInitialized || Camera.main == null)
            {
                return;
            }

            // Don't load if the application has quit and we're not in edit-time preview mode.
            if (HasQuit && (Application.isPlaying || !MapsService.MapPreviewOptions.Enable))
            {
                return;
            }

            // Set the loading flag to true before loading.
            // This flag is really used to let users of the map loader know about its current state.
            IsLoading = true;

            // Notify all listeners that we are starting to load the map
            if (MapLoadingStartedEvent != null)
            {
                MapLoadingStartedEvent.Invoke();
            }

            // Load the visible map region.
            MapsService.MakeMapLoadRegion()
            .AddViewport(Camera.main, MaxDistance)
            .Load(RenderingStyles);
        }
Exemplo n.º 3
0
    /// <summary>
    /// Get the required <see cref="DynamicMapsService"/> on this <see cref="GameObject"/>, waiting
    /// until is has initialized before loading a 300km circle around the center of Korea at zoom
    /// level 6.
    /// </summary>
    private void Awake()
    {
        DynamicMapsService dynamicMapsService = GetComponent <DynamicMapsService>();

        dynamicMapsService.OnMapLoadStarted.AddListener(() => {
            MapsService mapsService = dynamicMapsService.MapsService;
            mapsService.MakeMapLoadRegion()
            .AddCircle(mapsService.Coords.FromLatLngToVector3(KoreaCenter), 300000)
            .Load(dynamicMapsService.RenderingStyles, 6);
        });
    }
    void LoadMap()
    {
        mapsService.MakeMapLoadRegion().
        AddViewport(Camera.main, 10000f).
        Load(mapObjectOptions);



        //mapsService.LoadMap(ExampleDefaults.DefaultBounds,ExampleDefaults.DefaultGameObjectOptions);
        //_ShowAndroidToastMessage("LoadMap called and executed");
        //mapsService.LoadMap(ExampleDefaults.DefaultBounds,ExampleDefaults.DefaultGameObjectOptions);
        //mapsService.LoadMap(mapsService.GetPreviewBounds(), mapsService.MaybeGetGameObjectOptions());
    }
Exemplo n.º 5
0
    /// <summary>
    /// Calculates a map region based on the frustum of the default camera, and calls
    /// <see cref="MapsService"/> to load the calculated region.
    /// </summary>
    private void DoLoadVisibleMap()
    {
        if (Camera.main.transform.position == CameraPosition &&
            Camera.main.transform.rotation == CameraRotation)
        {
            return;
        }
        CameraPosition = Camera.main.transform.position;
        CameraRotation = Camera.main.transform.rotation;

        MapsService.MakeMapLoadRegion().AddViewport(Camera.main)
        .Load(ExampleDefaults.DefaultGameObjectOptions);
    }
Exemplo n.º 6
0
    /// <summary>
    /// Configures the map.
    /// </summary>
    private void Start()
    {
        MapsService mapsService = GetComponent <MapsService>();

        mapsService.InitFloatingOrigin(LoadingCenter);

        Material adminAreaMaterial = BaseMapMaterialUtils.CreateUniformColoredMaterial(AdminAreaColor);

        // Configure the map to only show prefectures and texture them with a solid color.
        mapsService.Events.RegionEvents.WillCreate.AddListener(args => {
            if (args.MapFeature.Metadata.Usage == RegionMetadata.UsageType.AdministrativeArea1)
            {
                RegionStyle.Builder style = args.Style.AsBuilder();
                style.FillMaterial        = adminAreaMaterial;
                args.Style = style.Build();
            }
            else
            {
                args.Cancel = true;
            }
        });

        // When a prefecture GameObject is created, create an extruded outline for it.
        Material borderMaterial = null;

        mapsService.Events.RegionEvents.DidCreate.AddListener(args => {
            if (borderMaterial == null)
            {
                // Set up the border material based on the prefecture material, but change the render queue
                // so that it renders on top.
                borderMaterial       = new Material(args.GameObject.GetComponent <Renderer>().material);
                borderMaterial.color = BorderColor;
                borderMaterial.renderQueue++;
            }
            Extruder.AddAreaExternalOutline(args.GameObject, borderMaterial, args.MapFeature.Shape,
                                            BorderWidth);
        });

        // Don't display water.
        mapsService.Events.AreaWaterEvents.WillCreate.AddListener(args => {
            args.Cancel = true;
        });

        // Load the map around Japan.
        mapsService.MakeMapLoadRegion()
        .AddCircle(mapsService.Coords.FromLatLngToVector3(LoadingCenter), 2000000) // 2,000 km.
        .Load(ExampleDefaults.DefaultGameObjectOptions, 5);                        // Zoom level 5.
    }
        /// <summary>
        /// Starts the loading of a Map Region defined by the viewport located at MaxDistance from the
        /// main Camera.
        /// </summary>
        public virtual void LoadMap()
        {
            if (MapsService == null || RenderingStyles == null || !IsInitialized || Camera.main == null)
            {
                return;
            }

            // Set the loading flag to true before loading.
            // This flag is really used to let users of the map loader know about its current state.
            IsLoading = true;

            // Notify all listeners that we are starting to load the map
            if (MapLoadingStartedEvent != null)
            {
                MapLoadingStartedEvent.Invoke();
            }

            // Load the visible map region.
            MapsService.MakeMapLoadRegion()
            .AddViewport(Camera.main, MaxDistance)
            .Load(RenderingStyles);
        }