Reputation: 3857
I haven’t been able to find documentation on it - Is it possible to have a marker always be centered on the map - have the map be moveable but the marker always in the center of it?
Any help is greatly appreciated!
Update - here is the JS we're currently using:
<script src="https://js.api.here.com/v3/3.0/mapsjs-core.js" type="text/javascript" charset="utf-8"></script>
<script src="https://js.api.here.com/v3/3.0/mapsjs-service.js" type="text/javascript" charset="utf-8"></script>
<script src="https://js.api.here.com/v3/3.0/mapsjs-ui.js" type="text/javascript" charset="utf-8"></script>
<script src="https://js.api.here.com/v3/3.0/mapsjs-mapevents.js" type="text/javascript" charset="utf-8"></script>
Upvotes: 2
Views: 1406
Reputation:
You can register a 'sync' event listener and then retrieve the center of the map any time the map view changes. You can then set the position of your marker to the retrieved center coordinates. See code snippet:
map.getViewModel().addEventListener('sync', function() {
var center = map.getCenter();
// Set marker position here:
// <marker object>.setPosition(center);
});
Upvotes: 2