-
Notifications
You must be signed in to change notification settings - Fork 128
Attaching GameObjects to the map
The MapPin component can be added to GameObjects which you want to attach to the MapRenderer at a specific lat-lon. When attached, the MapRenderer will take over management of the MapPin GameObject's transform.
There are two approaches that can be used to attach a MapPin to a MapRenderer. Both approaches are used in the demo scene.
The first approach is simply adding a child GameObject to the MapRenderer where this GameObject has a MapPin component. The MapRenderer detects any immediate child MapPin component and will takeover positioning the GameObject based on it's lat long.
This approach is good if you just have a few unique objects that need to be pinned to the map.
This approach is better suited for large data sets where clustering may be required:
-
Add a
MapPinLayer
component to the MapRenderer's GameObject. If clustering is enabled, check this setting on the layer and attach a prefab that has a ClusterMapPin component. -
In a script, get a reference to the
MapPinLayer
and addMapPin
instances to the the layer'sMapPins
collection.
An advantage to using the MapPinLayer is that it supports clustering. If a ClusterMapPin prefab is specified on the layer, MapPins will be clustered automatically. When MapPins are clustered, the ClusterMapPin is shown in the place of the many MapPins that associate to it.
Clustering is highly recommended for large datasets as this will reduce the number of MapPin instances that need to be rendered for zoomed out views. Besides this rendering performance benefit, it is often preferable to cluster MapPins from a usability perspective since dense, cluttered views will make it more difficult for the user to interact with individual MapPins.
Clusters are created at every zoom level, so as the zoom level of the MapRenderer changes, the visible clusters and MapPins may change as well.
Creating and adding many MapPins at once, either to a MapPinLayer or as children of the MapRenderer, could be time consuming and thus cause a frame hitch. If the MapPins can be initialized and added all at startup, this may be an acceptable one time hit. However, if data is being streamed and converted to MapPins throughout the app's lifetime, consider spreading out the MapPin creation and addition over multiple frames, i.e. time slice the additions. This will help to maintain render performance.
- Configuring the map
- Attaching GameObjects
- Adding labels
- Animating the map
- Raycasting the map
- Displaying copyrights
- Customizing map data
- Displaying contour lines
- Microsoft.Geospatial
- Microsoft.Geospatial.VectorMath
-
Microsoft.Maps.Unity
- ClippingVolumeDistanceTextureResolution
- ClusterMapPin
- CoordinateClamping
- DefaultElevationTileLayer
- DefaultTextureTileLayer
- DefaultTrafficTextureTileLayer
- ElevationTile
- ElevationTileLayer
- ElevationTileLayerList
- FontStyle
- FontWeight
- HttpTextureTileLayer
- IMapSceneAnimationController
- Intersection
- IntersectionType
- IPinnable
- LanguageChangedEvent
- LatLonAltUnityEvent
- LatLonUnityEvent
- LatLonWrapper
- MapColliderType
- MapConstants
- MapContourLineLayer
- MapCopyrightAlignment
- MapCopyrightLayer
- MapDataCache
- MapDataCacheBase
- MapDeveloperKeySource
- MapImageryStyle
- MapImageryType
- MapInteractionController
- MapInteractionHandler
- MapLabel
- MapLabelLayer
- MapLayer
- MapMouseInteractionHandler
- MapPin
- MapPinLayer
- MapRenderer
- MapRendererBase
- MapRendererRaycastHit
- MapRendererTransformExtensions
- MapScaleRatioExtensions
- MapScene
- MapSceneAnimationController
- MapSceneAnimationKind
- MapSceneOfBoundingBox
- MapSceneOfLabelAndZoomLevel
- MapSceneOfLocationAndZoomLevel
- MapSession
- MapShape
- MapTerrainType
- MapTouchInteractionHandler
- ObservableList
- ObservableMapPinList
- ServiceOptions
- Style
- SystemLangaugeConverter
- TextureTile
- TextureTileLayer
- TextureTileLayerList
- TileLayer
- TileLayerList
- UnityTaskFactory
- UnityWebRequestAwaiter
- UnityWebRequestAwaiterExtensionMethods
- WaitForMapLoaded
- WaitForMapSceneAnimation
- Microsoft.Maps.Unity.Search