ol.proj.transform 座標系轉換
阿新 • • 發佈:2021-09-07
code
var s = [[547225.076059,3375153.970705],[547268.959189,3374903.376212],[547381.875693,3374854.140213],[547555.065457,3375144.238708],[547225.076059,3375153.970705]]; var ss = s.map((it, index) => { // mark(it[0], it[1], 80, `${index+1}`); return ol.proj.transform(it, SRS, 'EPSG:4326') }); new Polygon([ss]);
Polygon#transform
https://openlayers.org/en/latest/apidoc/module-ol_geom_Polygon-Polygon.html#transform
see
座標系 // 3857 google // 4326 WGS-84:是國際標準,GPS座標(Google Earth使用、或者GPS模組) // 2437 GCJ-02:中國座標偏移標準,Google Map、高德、騰訊使用 // BD-09:百度座標偏移標準,Baidu Map使用 座標系轉換 ‘EPSG:4326’-經緯度座標-WGS84 ‘EPSG:3857’- xy座標-web墨卡託 》》》: 1.var m_center=[116.35,39.9];//地圖中心點-經緯度座標 //經緯度轉至xy m_center = ol.proj.transform(m_center,‘EPSG:4326’, ‘EPSG:3857’ ); //反過來 2. var m_center=[12914838.35,4814529.9];//地圖中心點-xy座標 //經緯度轉至經緯度 m_center = ol.proj.transform(m_center, ‘EPSG:3857’ ,‘EPSG:4326’); ol3預設的座標系為3857,即在建立ol.map的時候,若不指定projection,則預設為EPSG:3857 ———————————————— 版權宣告:本文為CSDN博主「聽風許諾」的原創文章,遵循CC 4.0 BY-SA版權協議,轉載請附上原文出處連結及本宣告。 原文連結:https://blog.csdn.net/weixin_41591572/article/details/85263826