簡體   English   中英

OpenLayers:如何將 MousePosition 坐標的格式更改為 HDMS?

[英]OpenLayers: how to change format of MousePosition coordinates to HDMS?

我正在使用 MousePosition 控件來顯示鼠標移動時的坐標,但我顯示的輸出類似於:'7.85, 47.98' 但我想要這樣的輸出:'47° 58' 60.0″ N 7° 50 ' 60.0 英寸 E'。

JS

var mouseposition = new ol.control.MousePosition({
            projection: 'EPSG:4326',
            coordinateFormat: ol.coordinate.createStringXY(2),
            undefinedHTML: '',
            className: 'ol-mouse-position ol-control'
        });
        map.addControl(mouseposition);

我嘗試使用 toStringHDMS() 但它不是我想要的格式,我不知道是不是我用錯了

var mouseposition = new ol.control.MousePosition({
            projection: 'EPSG:4326',
            coordinateFormat: ol.coordinate.toStringHDMS(),
            undefinedHTML: '',
            className: 'ol-mouse-position ol-control'
        });
        map.addControl(mouseposition);

在此示例中,輸出為:-46.20849609375,-23.595295498937958

采用

coordinateFormat: ol.coordinate.toStringHDMS,

沒有()

createStringXY()是一個返回 CoordinateFormat 函數的函數

toStringHDMS已經是一個 CoordinateFormat 函數

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM