Issue
I am and Android/Java newbie and am having trouble creating a GeoPoint when I try to send it a variable, but it woks fine when I send it a literal value.
In the below code block, The toast message displays the correct latitude (retrieved from the strings.xml
How can I set the Latitude using a variable?
Integer intLat = Integer.valueOf(R.string.MexCityLat);
Toast.makeText(HelloGoogleMapsActivity.this, intLat, Toast.LENGTH_SHORT).show();
GeoPoint point = new GeoPoint(intLat , -99120000); //this puts my point near North Pole
//GeoPoint point = new GeoPoint(19240000, -99120000); //this puts my point in Mexico City
OverlayItem overlayitem = new OverlayItem(point, "Hola, Mundo!", "I'm in Mexico City!");
Solution
GeoPoint
public GeoPoint(int latitudeE6,int longitudeE6)
Constructs a GeoPoint with the given latitude and longitude, measured in microdegrees (degrees * 1E6).
Parameters:
latitudeE6 - The point's latitude. This will be clamped to between -80 degrees and +80 degrees inclusive, in order to maintain accuracy in the Mercator projection.
longitudeE6 - The point's longitude. This will be normalized to be greater than -180 degrees and less than or equal to +180 degrees.
Also refer this link for how to convert double,float to geopoint. and be sure you are getting right value for intLat
Answered By - Shankar Agarwal
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.