Пример #1
0
    /// <summary>
    /// Illustrates how to add custom markers over the globe using the AddMarker API.
    /// In this example a building prefab is added to a random city (see comments for other options).
    /// </summary>
    void AddMarkerOnRandomCity()
    {
        // Every marker is put on a spherical-coordinate (assuming a radius = 0.5 and relative center at zero position)
        Vector2 planeLocation;

        // Add a marker on a random city
        City city = map.cities[Random.Range(0, map.cities.Count)];

        planeLocation = city.unity2DLocation;

        // or... choose a city by its name:
//		int cityIndex = map.GetCityIndex("Moscow");
//		planeLocation = map.cities[cityIndex].unity2DLocation;

        // or... use the centroid of a country
//		int countryIndex = map.GetCountryIndex("Greece");
//		planeLocation = map.countries[countryIndex].center;

        // or... use a custom location lat/lon. Example put the building over New York:
//		map.calc.fromLatDec = 40.71f;	// 40.71 decimal degrees north
//		map.calc.fromLonDec = -74.00f;	// 74.00 decimal degrees to the west
//		map.calc.fromUnit = UNIT_TYPE.DecimalDegrees;
//		map.calc.Convert();
//		planeLocation = map.calc.toPlaneLocation;

        // Send the prefab to the AddMarker API setting a scale of 0.1f (this depends on your marker scales)
        GameObject star = Instantiate(Resources.Load <GameObject>("StarSprite"));

        map.AddMarker(star, planeLocation, 0.02f);


        // Fly to the destination and see the building created
        map.FlyToLocation(planeLocation);

        // Optionally add a blinking effect to the marker
        MarkerBlinker.AddTo(star, 3, 0.2f);
    }