MCPcopy Create free account
hub / github.com/Vishal-raj-1/Awesome-JavaScript-Projects / init

Function init

assets/js/deviceInfo.js:63–80  ·  view source on GitHub ↗

* Initialize the application. * Automatically called by the google maps API once it's loaded.

()

Source from the content-addressed store, hash-verified

61 * Automatically called by the google maps API once it's loaded.
62*/
63function 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

Callers

nothing calls this directly

Calls 4

createMapFunction · 0.85
createMarkerFunction · 0.85
trackLocationFunction · 0.85
getPositionErrorMessageFunction · 0.85

Tested by

no test coverage detected