Add markers(添加标记)

SpawnOnMap provides an outline of placing custom markers. It uses the Start() function to calculate initial marker positions, then uses Update() to update those positions every time the map changes (either from zooming or panning).

SpawnOnMap 提供了放置自定义标记的概要。 它使用 Start() 函数计算初始标记位置,然后使用 Update() 在地图每次发生变化(缩放或平移)时更新这些位置。

..
.
void Start()
{
  _locations = new Vector2d[_locationStrings.Length];
  _spawnedObjects = new List<GameObject>();
  for (int i = 0; i < _locationStrings.Length; i++)
  {
    var locationString = _locationStrings[i];
    _locations[i] = Conversions.StringToLatLon(locationString);
    var instance = Instantiate(_markerPrefab);
    instance.transform.localPosition = _map.GeoToWorldPosition(_locations[i], true);
+   instance.transform.localScale = new Vector3(_spawnScale, _spawnScale, _spawnScale);
    _spawnedObjects.Add(instance);
  }
}

private void Update()
{
  int count = _spawnedObjects.Count;
  for (int i = 0; i < count; i++)
  {
    var spawnedObject = _spawnedObjects[i];
    var location = _locations[i];
    spawnedObject.transform.localPosition = _map.GeoToWorldPosition(location, true);
  }
}

Use the SpawnOnMap script(使用 SpawnOnMap 脚本)

To use the SpawnOnMap script, add it as a Component to a Map GameObject. Below is a description of the variables.

要使用 SpawnOnMap 脚本,请将其作为组件添加到地图游戏对象。 下面是变量的描述。

VariablesDescription
Map

Map object on which to place custom markers.

(放置自定义标记的地图对象)

Location Strings

(位置字符串)

List of locations in latitude, longitude format.

(纬度、经度格式的位置列表)

Spawn Scale

(产卵规模)

Scale of spawned markers. Applied as uniform scale in all directions.

(生成标记的比例。 在所有方向上应用统一比例。)

Custom Prefab

(定制预制件)

Prefab that will be spawned on the map as the marker.

(将作为标记生成在地图上的预制件。)

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值