How to change the value of a variable in Google map on mobile screen?

I want the value to change posCenter on mobile screens. How to do it?
function initMap() {
 // Styles is a map in night mode.
 var posCenter = {lat: 59.964556, lng: 30.276000}
 var uluru = {lat: 59.964556, lng: 30.280207};
 var map = new google.maps.Map(document.getElementById('map'), {
 center: posCenter,
 zoom: 16,

});
 var marker = new google.maps.Marker({
 position: uluru,
 map: map,
 icon: '<?php bloginfo('template_directory') ?>/img/marker.png'
});
 }
April 3rd 20 at 18:33
1 answer
April 3rd 20 at 18:35
1. Google:
(
- How to detect user device JS ||
- How to detect screen width with JS ||
- How to detect user agent js
)

2. Google: if statement, js
3. You put it all together.

Find more questions by tags JavaScriptGoogle Maps