本文整理匯總了Java中com.google.code.gwt.geolocation.client.Position類的典型用法代碼示例。如果您正苦於以下問題:Java Position類的具體用法?Java Position怎麽用?Java Position使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Position類屬於com.google.code.gwt.geolocation.client包,在下文中一共展示了Position類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onSuccess
import com.google.code.gwt.geolocation.client.Position; //導入依賴的package包/類
public void onSuccess(Position position) {
Coordinates c = position.getCoords();
geoLocationMap.put(LATITUDE, c.getLatitude());
geoLocationMap.put(LONGITUDE, c.getLongitude());
geoLocationMap.put(ACCURACY, c.getAccuracy());
geoLocationMap.put(ALTITUDE, c.hasAltitude() ? c.getAltitude()
: NO_VALUE);
geoLocationMap.put(ALTITUDE_ACCURACY,
c.hasAltitudeAccuracy() ? c.getAltitudeAccuracy()
: NO_VALUE);
geoLocationMap.put(HEADING, c.hasHeading() ? c.getHeading()
: NO_VALUE);
geoLocationMap.put(SPEED, c.hasSpeed() ? c.getSpeed() : NO_VALUE);
log("In OnSuccess:" + geoLocationMap.toString());
}
示例2: requestPosition
import com.google.code.gwt.geolocation.client.Position; //導入依賴的package包/類
private void requestPosition()
{
geo.getCurrentPosition(new PositionCallback() {
public void onFailure(PositionError error)
{
String message = "";
switch (error.getCode()) {
case PositionError.UNKNOWN_ERROR:
message = "Unknown Error";
break;
case PositionError.PERMISSION_DENIED:
message = "Permission Denied";
break;
case PositionError.POSITION_UNAVAILABLE:
message = "Position Unavailable";
break;
case PositionError.TIMEOUT:
message = "Time-out";
break;
default:
message = "Unknown error code.";
}
RootPanel.get("error").add(
new Label("Message: '" + error.getMessage() + "', code: " + error.getCode() + " (" + message + ")"));
}
public void onSuccess(Position position)
{
Coordinates c = position.getCoords();
final LatLng point = LatLng.newInstance(c.getLatitude(), c.getLongitude());
final String url = URL_STATIC + "?pos=" + point.toUrlValue();
addLinks(url, "");
}
}, PositionOptions.getPositionOptions(true /* GPS if possible */, 60000 /* timeout 1min */, 0 /* new position */));
}