List of usage examples for com.google.gwt.geolocation.client Geolocation isSupported
public static boolean isSupported()
true
if the browser supports geolocation. From source file:com.google.maps.gwt.samples.basics.client.MapGeolocation.java
License:Apache License
@Override public void onModuleLoad() { final MapOptions myOptions = MapOptions.create(); myOptions.setZoom(14.0);/*from w w w. j a va 2 s. c o m*/ myOptions.setMapTypeId(MapTypeId.ROADMAP); map = GoogleMap.create(Document.get().getElementById("map_canvas"), myOptions); // Try W3C Geolocation (Preferred) if (Geolocation.isSupported()) { browserSupportFlag = true; Geolocation.getIfSupported().getCurrentPosition(new Callback<Position, PositionError>() { @Override public void onSuccess(Position result) { Coordinates coords = result.getCoordinates(); initialLocation = LatLng.create(coords.getLatitude(), coords.getLongitude()); map.setCenter(initialLocation); } @Override public void onFailure(PositionError reason) { MapGeolocation.this.handleNoGeolocation(browserSupportFlag); } }); } else { browserSupportFlag = false; handleNoGeolocation(browserSupportFlag); } }