Using Google Weather API with Lat and Lon - how to format?

后端 未结 4 715
星月不相逢
星月不相逢 2020-12-17 02:45

I want to use the Google Weather API - by passing lat and long values. I am storing these values, however it seems Google needs these values in different format.

i.e

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-17 03:20

    In my opinion longitude an latitude must be coded in _e6 format (six last digits must be the decimal part of the lon/lat string passed to the API). Then you must adjust first decimals to a length of six, you add 0s if you have fewer than six decimals, and you clip it to 6, if you have more. For the int part if you have just one character you must add a zero first, for two or three digits, you don't need to do anything.

    Examples:

    • 1.1234 must be coded as: -01123400
    • 112.2345 must be coded as: 112234500
    • 34.123456 must be coded as

    Here you have a explanation with examples and a the php source code (the blog is written in Spanish).

提交回复
热议问题