简体   繁体   中英

How to show mouse position of latituds and logituds to MGRS in Openlayers3?

I have integrated openlayers3 in my project and it shows mouse position into latitudes and longitudes format. What I want is to show mouse position in MGRS format as well. How to do that please help.Demo Here

The MousePosition control takes an optional coordinateFormat function, that takes the coordinate as an argument and returns a formatted string.

You could write your own or use a built in. I'm not sure what you mean by "GPS format", but assuming that it is the latitude and longitude in hours, minutes and seconds as produce by ol.coordinate.toStringHDMS .

var mousePositionControl = new ol.control.MousePosition({
  coordinateFormat: ol.coordinate.toStringHDMS,
  projection: 'EPSG:4326'
});

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