简体   繁体   中英

In google maps javascript api - how to move map not marker

currently i have a little project that needs to make marker static and move map to the marker display on the map - i hope it makes any sense -

how to move map not marker - like i said the marker cannot move but the map needs to move to the marker when location changed - also marker is displayed at the bottom the map to make room for other events above the marker such as a path display and etc -

whats done already is when car moves it watches gps - then tells marker to move to that gps as a current location and then panby to the bottom of the map - this makes marker jerk at the bottom of the map when its location changed - so i figured if i keep marker static by placing it into a div above map and fixate it via css style - so it stays in the same place all the time - but this is wrong as it cannot be moved with map then when someone drags map with a finger - so this cannot be right solution - what is your solution to this dilema unless i am missing something -

You can use setCenter to center the map on a specifiq latLng location.

// your map
gMap = new google.maps.Map(document.getElementById('map')); 
// center to Palo Alto for exemple
gMap.setCenter(new google.maps.LatLng(37.4419, -122.1419));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM