0 Star 36 Fork 12

exlimit / tiler

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
map.go 1.72 KB
一键复制 编辑 原始数据 按行查看 历史
package main
import (
"fmt"
"strconv"
"strings"
"github.com/paulmach/orb/maptile"
)
// TileMap 瓦片地图类型
type TileMap struct {
ID int
Name string
Description string
Schema string //no types,maybe "xyz" or "tms"
Min int
Max int
Format string
JSON string
URL string
Token string
//such as porxy...
}
// CreateTileMap 添加地图
func CreateTileMap(url string) {
// tileMap := TileMap{}
//tileMap.Save()
//成功默认保存到数据库
}
// GetTileMapList 获取初始化默认地图列表
func GetTileMapList() map[int]TileMap {
tml := make(map[int]TileMap)
var list = []string{"http://mt0.google.com/vt/lyrs=y&x={x}&y={y}&z={z}",
"http://tile.openstreetmap.org/{z}/{x}/{y}.png",
"http://api.mapbox.com/v4/mapbox.satellite/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoiYWVyb3Zpc2lvbmtlc3RyZWwiLCJhIjoiY2l5bDhzYTVqMDAxNDJ3bGp1ZHA2cmtiaCJ9.8o3pqTWKiOV8RhjNGFW0rg",
// "http://mt0.google.cn/vt/lyrs=s&hl=zh-CN&x=214130&y=114212&z=18",
"http://mt0.google.cn/vt/lyrs=y&hl=zh-CN&x={x}&y={y}&z={z}",
"http://mt0.google.cn/vt/lyrs=s&x={x}&y={y}&z={z}",
"http://mt0.google.cn/vt/lyrs=y@258000000&hl=zh-CN&gl=CN&src=app&x=214130&y=114212&z=18&s=Ga", //m:路线图,t:地形图,p:带标签的地形图,s:卫星图,y:带标签的卫星图,h:标签层(路名、地名等)
}
for i, v := range list {
fmt.Println(i, v)
m := TileMap{}
tml[i] = m
}
return tml
}
// TileURL 获取瓦片URL
func (m TileMap) getTileURL(t maptile.Tile) string {
url := strings.Replace(m.URL, "{x}", strconv.Itoa(int(t.X)), -1)
url = strings.Replace(url, "{y}", strconv.Itoa(int(t.Y)), -1)
url = strings.Replace(url, "{z}", strconv.Itoa(int(t.Z)), -1)
return url
}
Go
1
https://gitee.com/exlimit/tiler.git
git@gitee.com:exlimit/tiler.git
exlimit
tiler
tiler
master

搜索帮助