Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

google maps api coordinates from java to javascript

If I want to share my geocoded spots in javascript and java how is this possible?

In Javascript the points are specified as

var point = GPoint(76.27562,9.97943);

In Java they are

GeoPoint point = new GeoPoint(45005000, -93228900);

those seem to be two different formats, so how do I convert from one to the other?

like image 324
Jakob Avatar asked Feb 25 '26 07:02

Jakob


1 Answers

GeoPoint requires lat/lng to be passed as integers, with degrees multiplied by 10^6. So, you would need to multiply 76.27562 by 10^6 and convert that into an integer before passing it to the GeoPoint. The reverse process needs to be done for the reverse transformation.

Taken from here:

GeoPoint(int latitudeE6, int longitudeE6) Constructs a GeoPoint with the given latitude and longitude, measured in microdegrees (degrees * 1E6).

1E6 is 10^6

like image 71
Gabi Purcaru Avatar answered Feb 27 '26 22:02

Gabi Purcaru