Hello,

I use the code below to get the long lat of the location where the user clicked on a Google Map (in Android).

Projection p = map.getProjection();
geoPoint = p.fromPixels((int) e.getX(), (int) e.getY());

It gives me coordinates, however it does not place a decimal in the geoPoint. Any suggestions on how to do this? Thanks.

does not place a decimal in the geoPoint.

Please explain and give an example.

Once I run the lines above it gets this:

51315403,94536620

I need a decimal in the x,y such as:

37.422005,-122.084095

When I load my map, the pinpoint is completely off, I need the decimal place.

Thanks

Can you explain how 51315403 is converted to 37.422005?
etc
What is 51315403? What does it measure? What units is it in?
The 37.422005 looks like its a North latitude.

Its not, that is just an example of what another coordinate is.

I get 37.422005 from double lat = location.getLatitude(); which location is type Location. Completely different part of program.

What is 51315403? What does it measure? What units is it in?
Does it need to be converted to degrees latitude?

I open up my Google maps, hover over Asia, click on a part in Asia and insert that location. It gets the location from geoPoint = p.fromPixels((int) e.getX(), (int) e.getY());. I could hover over Finland or Mexico and do the same thing. I just do not know why it does not place a decimal in the x,y coordinates.

There are different global mapping schemes. You are looking for lat/long. What are you getting from the fromPixels() method? You need to read the API doc to see what you are getting and then find the class and methods to convert that to what you want.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.