Package totalcross.map
Class GoogleMaps
- java.lang.Object
-
- totalcross.map.GoogleMaps
-
public class GoogleMaps extends java.lang.ObjectShows a Google Maps viewer on a separate screen. Pressing back returns to the application. Internet connection is required. Currently works in Android and iOS only.- Since:
- TotalCross 1.3
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classGoogleMaps.CircleA map item that represents a circle.static classGoogleMaps.MapItemAn abstract class used to group an array of map items.static classGoogleMaps.PlaceA map item that represents a place in the map.static classGoogleMaps.ShapeA map item that represents a polygon with any shape.
-
Field Summary
Fields Modifier and Type Field Description static intSHOW_SATELLITE_PHOTOSUsed in the flags argument of showRoute: shows the satellite photos.static intUSE_WAZEUsed in the flags argument of showRoute: use waze to show the route of the current location to a target address.
-
Constructor Summary
Constructors Constructor Description GoogleMaps()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static double[]getLocation(java.lang.String address)Returns the location after searching Google.static booleanshowAddress(java.lang.String address, boolean showSatellitePhotos)Shows the given address in a separate viewer.static booleanshowMap(GoogleMaps.MapItem[] items, boolean showSatellitePhotos)Shows an array of MapItem elements in the map.static booleanshowRoute(java.lang.String addressI, java.lang.String addressF, java.lang.String traversedPoints, boolean showSatellitePhotos)Deprecated.static booleanshowRoute(java.lang.String addressI, java.lang.String addressF, java.lang.String traversedPoints, int flags)Shows the route between two points.
-
-
-
Field Detail
-
SHOW_SATELLITE_PHOTOS
public static final int SHOW_SATELLITE_PHOTOS
Used in the flags argument of showRoute: shows the satellite photos.- See Also:
- Constant Field Values
-
USE_WAZE
public static final int USE_WAZE
Used in the flags argument of showRoute: use waze to show the route of the current location to a target address. Note that the destination address is NOT used.- See Also:
- Constant Field Values
-
-
Method Detail
-
showAddress
public static boolean showAddress(java.lang.String address, boolean showSatellitePhotos)Shows the given address in a separate viewer. If you want to show your current location, you will have to turn GPS on, get the coordinates and pass to this method. See the tc.samples.map.GoogleMaps sample.- Parameters:
address- The address (WITHOUT ACCENTUATION) to show (E.G.: "rua tonelero 10, copacabana, rio de janeiro, brasil", or "22030,brasil"). The address is resolved and its latitude and logitude coordinates are retrieved. Careful with the address given, be sure to make some tests before. To remove accentuation, you can use Convert.removeAccentuation. If you want to pass the lat/lon coordinates, pass them in the form: "@lat,lon" (E.G.: "@-22.966000,-43.185000"). Note that, due to Android's restrictions, only the first 6 decimal digits in the coordinates are used. Passing an empty string will make the engine search for a valid "last known position". If there's no such position, it will return false.showSatellitePhotos- If true, an image of the satellite is combined with the map. May require more bandwidth and internet resources.- Returns:
- true if the map was shown, false otherwise. False is often returned when there's no internet connection.
- See Also:
Convert.removeAccentuation(String)
-
showRoute
@Deprecated public static boolean showRoute(java.lang.String addressI, java.lang.String addressF, java.lang.String traversedPoints, boolean showSatellitePhotos) throws NotInstalledExceptionDeprecated.Shows the route between two points. The traversed points is a sequence of lat,lon coordinates comma-separated.- Throws:
NotInstalledException- See Also:
showRoute(String, String, String, int)
-
showRoute
public static boolean showRoute(java.lang.String addressI, java.lang.String addressF, java.lang.String traversedPoints, int flags) throws NotInstalledExceptionShows the route between two points. The traversed points is a sequence of lat,lon coordinates comma-separated. If flags is USE_WAZE, the addressF is not used and can be null, and a NotInstalledException is thrown if WAZE is not installed. Note that you must remove accentuation from addressI and addressF; you may use Convert.removeAccentuation.- Throws:
NotInstalledException- See Also:
Convert.removeAccentuation(String)
-
showMap
public static boolean showMap(GoogleMaps.MapItem[] items, boolean showSatellitePhotos)
Shows an array of MapItem elements in the map. The map is zommed in a way that all coordinates are visible. If one may pass multiple overlapping items (let's say, items[0], items[1] and items[2]), one item will cover all the previous items (item[1] will be over item[0]; item[2] will be over item[1] and item[0]).
-
getLocation
public static double[] getLocation(java.lang.String address) throws IOException, InvalidNumberExceptionReturns the location after searching Google. Requires internet connection and waits up to 20 seconds for an answer. Returns the lat/lon pair, or null if a bad response code was returned.- Throws:
IOExceptionInvalidNumberException
-
-