简体   繁体   中英

Add marker to google maps by using GeoJson

I have no idea how to add a marker from a GeoJson .

The data I have to use is something like:

"geometry": {  
        "type":"Point",
        "coordinates":[  
           727053.159,
           4374119.505
        ]
     }

I supposed the coordinates would be Latitude and Longitude but what I have tried doesn't work:

private fun createMarker(
    latitude: Double,
    longitude: Double,
    title: String,
    snippet: String
): Marker {
    return mMap.addMarker(
        MarkerOptions()
            .position(LatLng(latitude, longitude))
            .title(title)
            .snippet(snippet)
    )
}

Any idea how to add the marker from geojson data?

Andrew Reid is absolutely right: your GeoJSON data is not in WGS84 Latitude/Longitude degrees. You should determine coordinate reference system (CRS) of your GeoJSON eg by checking its "crs" tag. If there is "crs" here is some tips how to determine unknown coordinate system. I would start trying from UTM .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM