Skip to content

Commit

Permalink
Merge pull request #738 from 3DStreet/osm4vr-testing
Browse files Browse the repository at this point in the history
change to map selector, reduce google3d tiles distanceScale
  • Loading branch information
kfarr authored Jul 29, 2024
2 parents 814526d + 6c90b04 commit dea7feb
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/components/street-geo.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,20 @@ AFRAME.registerComponent('street-geo', {
orthometricHeight: { type: 'number', default: null },
geoidHeight: { type: 'number', default: null },
ellipsoidalHeight: { type: 'number', default: null },
maps: { type: 'array', default: [] }
maps: {
type: 'string',
default: 'google3d',
oneOf: ['google3d', 'mapbox2d']
}
},
init: function () {
/*
Function names for the given function types must have the following format:
create function: <mapType>Create,
update function: <mapType>Update,
*/
this.mapTypes = ['mapbox2d', 'google3d'];
this.elevationHeightConstant = 32.49158;
this.mapTypes = this.el.components['street-geo'].schema.maps.oneOf;
this.elevationHeightConstant = 32.49158; // deprecated

const urlParams = new URLSearchParams(window.location.search);
this.isAR = urlParams.get('viewer') === 'ar';
Expand All @@ -43,20 +47,20 @@ AFRAME.registerComponent('street-geo', {
const updatedData = AFRAME.utils.diff(oldData, data);

for (const mapType of this.mapTypes) {
if (data.maps.includes(mapType) && !this[mapType]) {
if (data.maps === mapType && !this[mapType]) {
// create Map element and save a link to it in this[mapType]
if (!this.isAR) {
this[mapType + 'Create']();
}
} else if (
data.maps.includes(mapType) &&
data.maps === mapType &&
(updatedData.longitude ||
updatedData.latitude ||
updatedData.ellipsoidalHeight)
) {
// call update map function with name: <mapType>Update
this[mapType + 'Update']();
} else if (this[mapType] && !data.maps.includes(mapType)) {
} else if (this[mapType] && data.maps !== mapType) {
// remove element from DOM and from this object
this.el.removeChild(this[mapType]);
this[mapType] = null;
Expand Down Expand Up @@ -116,11 +120,11 @@ AFRAME.registerComponent('street-geo', {
// set this to ellipsoidalHeight
height: height,
googleApiKey: firebaseConfig.apiKey,
geoTransform: 'WGS84Cartesian',
maximumSSE: 16,
maximumMem: 400,
cameraEl: '#camera',
copyrightEl: '#map-copyright'
copyrightEl: '#map-copyright',
distanceScale: 0.5
});
google3dElement.classList.add('autocreated');

Expand Down

0 comments on commit dea7feb

Please sign in to comment.