本文整理汇总了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 */));
}