0

How will I plot a marker on Google Map with my geometry points? Here is the sample geometry points POINT Z (642823.3317 937067.5592999998 0).

I added a JTS dependencies which is org.locationtech.jts. Here is my code:

// get the POINT Z (642823.3317 937067.5592999998 0)
String geometryPoints = record.getGeometry();

// parse the points using JTS
WKTReader reader = new WKTReader();
Geometry geometry = reader.read(geometryPoints);

if (geometry instanceof Point) {
   double lat = geometry.getCoordinate().y;
   double lng = geometry.getCoordinate().x;

   LatLng position = new LatLng(lat, lng);

   mMap.addMarker(new MarkerOptions()
      .position(position)
      .title(record.getKilometerPostId())
      .snippet(record.getXsp())
      .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE)));
}

I also logged the geometry.getCoordinate().x and it print on my Logcat. However, it does not show on my Google Map. What maybe the problem?

Thank you for the help!

2
  • what is value you get in log for geometry.getCoordinate().x ? Commented Apr 22 at 3:05
  • 2
    You need to define what is the coordinate reference system (CRS) used and then provide a transform to WGS84 to then use in google maps. Google maps simply doesn't display points outside ( [-90,90], [-180,180] ). Commented Apr 22 at 22:44

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.