From 6fa70dbad1510d8dd10804757ef380b37d35cb57 Mon Sep 17 00:00:00 2001 From: Alexander Goryushkin Date: Fri, 17 May 2024 18:58:00 -0400 Subject: [PATCH] add documentation --- src/components/street-geo.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/components/street-geo.js b/src/components/street-geo.js index 286c4ccfa..ab5b38c5d 100644 --- a/src/components/street-geo.js +++ b/src/components/street-geo.js @@ -2,7 +2,21 @@ const MAPBOX_ACCESS_TOKEN_VALUE = 'pk.eyJ1Ijoia2llcmFuZmFyciIsImEiOiJjazB0NWh2YncwOW9rM25sd2p0YTlxemk2In0.mLl4sNGDFbz_QXk0GIK02Q'; const GOOGLE_API_KEY = 'AIzaSyAQshwLVKTpwTfPJxFEkEzOdP_cgmixTCQ'; - +/* + * Street-geo component + * + * the component accept longitude, latitude, elevation and an array of map types to indicate + * which child maps to spawn. Possible values for maps array: 'mapbox2d', 'google3d'. + * The component assigns the class 'autocreated' to its child elements. + * All attribute values can be changed at runtime and the component will update + * the child elements (map entities) and their corresponding parameters. + * The 'elevation' attribute is only used for the 'google3d' tiles element for now. + * + * to add support for a new map type, you need to take the following steps: + * - add map name to this.mapTypes variable + * - add creating function with name: Create + * - add update function with name: Update + */ AFRAME.registerComponent('street-geo', { schema: { longitude: { type: 'number', default: 0 }, @@ -28,8 +42,8 @@ AFRAME.registerComponent('street-geo', { for (const mapType of this.mapTypes) { // create map function with name: Create const createElementFunction = this[mapType + 'Create'].bind(this); - // create Map element and save a link to it in this[mapType] if (data.maps.includes(mapType) && !this[mapType]) { + // create Map element and save a link to it in this[mapType] this[mapType] = createElementFunction(); } else if (data.maps.includes(mapType) && (updatedData.longitude || updatedData.latitude || updatedData.elevation)) { // call update map function with name: Update