CEC-4955 - Digital Twin map zooms to location of car (#428)
* CEC-4955 - Digital twin show vehicle location * fix code smell * CEC-4955 - Zoom to location of car
This commit is contained in:
@@ -279,8 +279,8 @@ exports[`DigitalTwinTab Render 1`] = `
|
||||
alt=""
|
||||
class="leaflet-tile"
|
||||
role="presentation"
|
||||
src="https://b.tile.openstreetmap.org/5/7/12.png"
|
||||
style="width: 256px; height: 256px; left: -126px; top: -114px;"
|
||||
src="https://c.tile.openstreetmap.org/5/5/12.png"
|
||||
style="width: 256px; height: 256px; left: -30px; top: -95px;"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -299,7 +299,7 @@ exports[`DigitalTwinTab Render 1`] = `
|
||||
class="leaflet-marker-icon leaflet-zoom-hide leaflet-interactive"
|
||||
role="button"
|
||||
src="gray-marker.png"
|
||||
style="margin-left: -24px; margin-top: -42px; opacity: 0.9; left: -608px; top: -19px; z-index: -19;"
|
||||
style="margin-left: -24px; margin-top: -42px; opacity: 0.9; left: 0px; top: 0px; z-index: 0; z-index: 0; z-index: 0; z-index: 0; z-index: 0; z-index: 0; z-index: 0; z-index: 0; z-index: 0;"
|
||||
tabindex="0"
|
||||
title="TESTVIN1234567890"
|
||||
/>
|
||||
|
||||
@@ -85,13 +85,23 @@ const Component = (props) => {
|
||||
};
|
||||
|
||||
const centerAroundMarkers = (points) => {
|
||||
let defaultLocationJSON = process.env.REACT_APP_HOME_MAP_DEFAULT_LOCATION;
|
||||
let defaultLocation = JSON.parse(defaultLocationJSON)
|
||||
|
||||
if (props.vin) {
|
||||
// center is the location of the specified vin
|
||||
if (points && points[0]) {
|
||||
setCenter([points[0][0], points[0][1]]);
|
||||
setZoom(defaultLocation.zoom);
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if (lastMapCenter) {
|
||||
let zoomLocation = JSON.parse(lastMapCenter)
|
||||
setCenter(zoomLocation.center);
|
||||
setZoom(zoomLocation.zoom)
|
||||
} else {
|
||||
let defaultLocationJSON = process.env.REACT_APP_HOME_MAP_DEFAULT_LOCATION;
|
||||
let defaultLocation = JSON.parse(defaultLocationJSON)
|
||||
setCenter([defaultLocation.lat, defaultLocation.lng]);
|
||||
setZoom(defaultLocation.zoom);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user