Skip to content

TheMelody/OmniMap-Compose

Repository files navigation

OmniMap Compose 🗺

LICENSE issues forks stars 稀土掘金 知乎 CSDN

Compose一键集成5大地图神器

集成

gd_composeMaven Central
tencent_composeMaven Central
baidu_composeMaven Central
repositories {
  maven { url 'https://mirrors.tencent.com/nexus/repository/maven-public/' }
}

dependencies {
  // 根据自己项目情况,选择下面其中一种地图
  implementation 'io.github.TheMelody:gd_compose:<version>'       // 高德地图
  implementation 'io.github.TheMelody:tencent_compose:<version>'  // 腾讯地图
  implementation 'io.github.TheMelody:baidu_compose:<version>'    // 百度地图
  implementation 'io.github.TheMelody:huawei_compose:<version>'   // 花瓣地图(Android 7.0+) → 实现中
  implementation 'io.github.TheMelody:google_compose:<version>'   // Google地图 → 未开始
}

用法

  • 1、添加一个高德地图
val cameraPositionState = rememberCameraPositionState {
    position = CameraPosition.fromLatLngZoom(LatLng(39.984108,116.307557), 10F)
}
GDMap(
    modifier = Modifier.fillMaxSize(),
    cameraPositionState = cameraPositionState
){
    //这里面放地图覆盖物...
}
  • 2、添加一个腾讯地图
val cameraPositionState = rememberCameraPositionState {
   position =  TXCameraPosition(latLng = LatLng(39.984108,116.307557), zoom = 10F, tilt = 0F, bearing = 0F)
}
TXMap(
    modifier = Modifier.fillMaxSize(),
    cameraPositionState = cameraPositionState
){
    //这里面可以放地图覆盖物...
}
  • 3、添加一个百度地图
val cameraPositionState = rememberCameraPositionState {
    position = BDCameraPosition(LatLng(39.984108,116.307557), 4F, 0f, 0f)
}
BDMap(
    modifier = Modifier.fillMaxSize(),
    cameraPositionState = cameraPositionState
){
    //这里面可以放地图覆盖物...
}
  • 4、配置地图
// 高德地图
GDMap(
    modifier = Modifier.fillMaxSize(),
    properties = MapProperties(/**自行修改参数**/),
    uiSettings  = MapUiSettings(/**自行修改参数**/)
){
    //这里面可以放地图覆盖物...
}

//腾讯地图
TXMap(
    modifier = Modifier.fillMaxSize(),
    properties = MapProperties(/**自行修改参数**/),
    uiSettings  = MapUiSettings(/**自行修改参数**/)
){
    //这里面可以放地图覆盖物...
}

//百度地图
BDMap(
    modifier = Modifier.fillMaxSize(),
    properties = MapProperties(/**自行修改参数**/),
    uiSettings  = MapUiSettings(/**自行修改参数**/)
){
    //这里面可以放地图覆盖物...
}
  • 5、自定义Marker覆盖物的InfoWindow
// 只修改内容,不修改容器
MarkerInfoWindowContent(
    // ...
    title = "我是title",
    snippet = "我是snippet"
) { marker ->
    Column {
        Text(marker.title ?: "", color = Color.Green)
        Text(marker.snippet ?: "", color = Color.Red)
        // TODO: 如果是百度地图,请使用 marker.getTitleExt() 和 marker.getSnippetExt()
    }
}

// 修改整个信息窗(容器及内容)
MarkerInfoWindow(
    //...
    snippet = "我是一个卖报的小画家(自定义InfoWindow)"
) { marker ->
    Card(modifier = Modifier.requiredSizeIn(maxWidth = 88.dp, minHeight = 66.dp)) {
        Text(
            modifier = Modifier.padding(4.dp),
            text = marker.snippet ?: "", color = Color.Red)
        // TODO: 如果是百度地图,请使用 marker.getSnippetExt()
    }
}
  • 6、已支持的覆盖物
高德地图 Arc、Circle、ClusterOverlay、GroundOverlay、Marker、MovingPointOverlay、MultiPointOverlay、OpenGLOverlay、Polygon、Polyline、RoutePlanOverlay、TileOverlay
腾讯地图 Arc、Circle、ClusterOverlay、GroundOverlay、Marker、MovingPointOverlay、Polygon、Polyline、TileOverlay
百度地图 Arc、Circle、ClusterOverlay、GroundOverlay、Marker、MultiPointOverlay、Polygon、Polyline、TileOverlay、RoutePlanOverlay、TextOverlay、TraceOverlay、BM3DBuildOverlay、BM3DModelOverlay、BM3DPrismOverlay

更多能力,请查阅我们的示例Demo

License

MIT License

Copyright (c) 2023 被风吹过的夏天

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

About

🔥🔥🔥Compose一键集成5大地图平台地图

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages