google地图的Javascript十进制到度

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了google地图的Javascript十进制到度相关的知识,希望对你有一定的参考价值。

When you show the coordinates of a point, it’s sometimes better to show them as degrees and not as deciaml (even if decimal is simpler). Each of the two coordinates can be converted with the same function. In the function call the “tipo” is the type of the “v” value: if you call the function without the type, then the default type is “N”, that means “NORTH”, it means that you’re converting a Latitude value. Values for latitude type are “N” for NORTH and “S” for SOUTH.
If you specify “E” or “W” than you’re converting a Longitude value.
  1. function convertDecDeg(v,tipo) {
  2. if (!tipo) tipo='N';
  3. var deg;
  4. deg = v;
  5. if (!deg){
  6. return "";
  7. } else if (deg > 180 || deg < 0){
  8. // convert coordinate from north to south or east to west if wrong tipo
  9. return convertDecDeg(-v,(tipo=='N'?'S': (tipo=='E'?'W':tipo) ));
  10. } else {
  11. var gpsdeg = parseInt(deg);
  12. var remainder = deg - (gpsdeg * 1.0);
  13. var gpsmin = remainder * 60.0;
  14. var D = gpsdeg;
  15. var M = parseInt(gpsmin);
  16. var remainder2 = gpsmin - (parseInt(gpsmin)*1.0);
  17. var S = parseInt(remainder2*60.0);
  18. return D+"&deg; "+M+"' "+S+"'' "+tipo;
  19. }
  20. }

以上是关于google地图的Javascript十进制到度的主要内容,如果未能解决你的问题,请参考以下文章

JavaScript Javascript十进制到谷歌地图的度数

将 Google“我的地图”图层添加到 Google Maps Javascript API

加载后如何使用 JavaScript 调整 Google 地图的大小?

在 Javascript 中使用 DJango 模板标签添加 Google 地图标记

使用 Python“运行 Javascript”输入更新 Google 地图标记位置

javascript 重新排列Google地图块