* Initialize the application. * Automatically called by the google maps API once it's loaded.
()
| 61 | * Automatically called by the google maps API once it's loaded. |
| 62 | */ |
| 63 | function init() { |
| 64 | const initialPosition = { lat: 25.00, lng: 71.00 }; |
| 65 | const map = createMap(initialPosition); |
| 66 | const marker = createMarker({ map, position: initialPosition }); |
| 67 | |
| 68 | let watchId = trackLocation({ |
| 69 | onSuccess: ({ coords: { latitude: lat, longitude: lng } }) => { |
| 70 | marker.setPosition({ lat, lng }); |
| 71 | map.panTo({ lat, lng }); |
| 72 | |
| 73 | }, |
| 74 | onError: err => { |
| 75 | console.log($info); |
| 76 | $info.textContent = `Error: ${err.message || getPositionErrorMessage(err.code)}`; |
| 77 | $info.classList.add('error'); |
| 78 | } |
| 79 | }); |
| 80 | } |
| 81 | |
| 82 | |
| 83 |
nothing calls this directly
no test coverage detected