本文整理汇总了Java中org.osmdroid.api.IMapController.setCenter方法的典型用法代码示例。如果您正苦于以下问题:Java IMapController.setCenter方法的具体用法?Java IMapController.setCenter怎么用?Java IMapController.setCenter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.osmdroid.api.IMapController
的用法示例。
在下文中一共展示了IMapController.setCenter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mapSetup
import org.osmdroid.api.IMapController; //导入方法依赖的package包/类
private void mapSetup() {
map = (MapView) getActivity().findViewById(R.id.createPoiMap);
//important! set your user agent to prevent getting banned from the osm servers
Configuration.getInstance().load(getActivity(), PreferenceManager.getDefaultSharedPreferences(getActivity()));
map.setTileSource(TileSourceFactory.MAPNIK);
map.setTilesScaledToDpi(true);
// add multi-touch capability
map.setMultiTouchControls(true);
// add compass to map
CompassOverlay compassOverlay = new CompassOverlay(getActivity(), new InternalCompassOrientationProvider(getActivity()), map);
compassOverlay.enableCompass();
map.getOverlays().add(compassOverlay);
// get map controller
IMapController controller = map.getController();
GeoPoint position = new GeoPoint(latitude, longitude);
controller.setCenter(position);
controller.setZoom(18);
MapUtils.addMarker(getActivity(), map, latitude, longitude);
}
示例2: setupMapPreview
import org.osmdroid.api.IMapController; //导入方法依赖的package包/类
private void setupMapPreview(double lat, double lon, String markerTitle) {
//important! set your user agent to prevent getting banned from the osm servers
Configuration.getInstance().load(getDialog().getContext(), PreferenceManager.getDefaultSharedPreferences(getDialog().getContext()));
map = (MapView) getDialog().findViewById(R.id.poiDialogMap);
map.setTileSource(TileSourceFactory.MAPNIK);
map.setTilesScaledToDpi(true);
map.setMultiTouchControls(true);
// add compass to map
CompassOverlay compassOverlay = new CompassOverlay(getDialog().getContext(), new InternalCompassOrientationProvider(getDialog().getContext()), map);
compassOverlay.enableCompass();
map.getOverlays().add(compassOverlay);
// get map controller
IMapController controller = map.getController();
GeoPoint position = new GeoPoint(lat, lon);
controller.setCenter(position);
controller.setZoom(18);
MapUtils.addMarker(getActivity(), map, lat, lon, markerTitle);
}
示例3: mapSetup
import org.osmdroid.api.IMapController; //导入方法依赖的package包/类
private void mapSetup() {
map = (MapView) getActivity().findViewById(R.id.createPoiMap);
//important! set your user agent to prevent getting banned from the osm servers
Configuration.getInstance().load(getActivity(), PreferenceManager.getDefaultSharedPreferences(getActivity()));
map.setTileSource(TileSourceFactory.MAPNIK);
map.setTilesScaledToDpi(true);
map.setMultiTouchControls(true);
CompassOverlay compassOverlay = new CompassOverlay(getActivity(), new InternalCompassOrientationProvider(getActivity()), map);
compassOverlay.enableCompass();
map.getOverlays().add(compassOverlay);
IMapController controller = map.getController();
GeoPoint position = new GeoPoint(POI.getLatitude(), POI.getLongitude());
controller.setCenter(position);
controller.setZoom(18);
MapUtils.addMarker(getActivity(), map, POI.getLatitude(), POI.getLongitude());
}
示例4: configMap
import org.osmdroid.api.IMapController; //导入方法依赖的package包/类
private void configMap(){
map.setBuiltInZoomControls(true);
map.setMultiTouchControls(true);
map.setFlingEnabled(true);
IMapController mapController = map.getController();
mapController.setZoom(6);
GeoPoint startPoint = new GeoPoint(50.77623, 6.06937);
mapController.setCenter(startPoint);
SharedPreferences sharedPref = this.getActivity().getSharedPreferences("sharedPref", Context.MODE_PRIVATE);
String server = sharedPref.getString("server", "http://www.hampager.de:8080");
String user = sharedPref.getString("user", "invalid");
String password = sharedPref.getString("pass", "invalid");
fetchJSON(server,user,password);
}
示例5: onCreate
import org.osmdroid.api.IMapController; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
MapView mapView = (MapView) findViewById(R.id.map_view);
mapView.setTileSource(TileSourceFactory.PUBLIC_TRANSPORT);
mapView.setBuiltInZoomControls(true);
mapView.setMultiTouchControls(true);
IMapController mapController = mapView.getController();
mapController.setZoom(9);
GeoPoint location = new GeoPoint(27.7166667,85.3166667);
mapController.setCenter(location);
}
示例6: onCreate
import org.osmdroid.api.IMapController; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_request);
write();
move();
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
// initialize display map
map = (MapView) findViewById(R.id.addRequestMap);
map.setTileSource(TileSourceFactory.MAPNIK);
map.setBuiltInZoomControls(true);
map.setMultiTouchControls(true);
startPoint = new GeoPoint(53.52676, -113.52715);
IMapController mapController = map.getController();
mapController.setZoom(10);
mapController.setCenter(startPoint);
getLocations();
}
示例7: onCreate
import org.osmdroid.api.IMapController; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Initialize map
setContentView(R.layout.activity_map);
MapView map = (MapView) findViewById(R.id.map_Map);
map.setTileSource(TileSourceFactory.MAPNIK);
map.setBuiltInZoomControls(true);
map.setMultiTouchControls(true);
GeoPoint startPoint = new GeoPoint(53.52676, -113.52715);
IMapController mapController = map.getController();
mapController.setZoom(10);
mapController.setCenter(startPoint);
move();
}
示例8: onCreate
import org.osmdroid.api.IMapController; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_search_requests);
write();
move();
// Initialize map
map = (MapView) findViewById(R.id.Map);
map.setTileSource(TileSourceFactory.MAPNIK);
map.setBuiltInZoomControls(true);
map.setMultiTouchControls(true);
startPoint = new GeoPoint(53.52676, -113.52715);
IMapController mapController = map.getController();
mapController.setZoom(10);
mapController.setCenter(startPoint);
getLocation();
}
示例9: onCreateView
import org.osmdroid.api.IMapController; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
mContext = inflater.getContext();
mResourceProxy = new ResourceProxyImpl(mContext.getApplicationContext());
mMapView = new MapView(inflater.getContext(), 256, mResourceProxy);
mMapView.setTileSource(TileSourceFactory.MAPQUESTOSM);
mMapView.setBuiltInZoomControls(true);
mMapView.setMultiTouchControls(true);
mMapView.setUseDataConnection(true);
IMapController mapCtrl = mMapView.getController();
mapCtrl.setCenter(new GeoPoint(43.5, -80.5));
mapCtrl.setZoom(10);
mMapView.invalidate();
return mMapView;
}
示例10: zoom
import org.osmdroid.api.IMapController; //导入方法依赖的package包/类
private void zoom(MapView mapView, boolean ddragMode) {
if (isDebugEnabled()) debug("zoom",this);
// mapView.setC .zoomToBoundingBox(rect);
final Projection projection = mapView.getProjection();
IMapController controller = mapView.getController();
if (ddragMode) {
IGeoPoint start = projection.fromPixels(this.mStart.x, this.mStart.y);
IGeoPoint end = projection.fromPixels(this.mEnd.x, this.mEnd.y);
ZoomUtil.zoomTo(mapView, ZoomUtil.NO_ZOOM, start, end);
if (isDebugEnabled()) debug("zoom(ddrag mode)", start, "..", end,
"=>", mapView.getMapCenter(), "z=", mapView.getZoomLevel());
} else {
IGeoPoint center = projection.fromPixels(this.mStart.x, this.mStart.y);
controller.setCenter(center);
controller.zoomIn();
if (isDebugEnabled()) debug("zoom(to center of)", center,
"=>", mapView.getMapCenter(), "z=", mapView.getZoomLevel());
}
}
示例11: onCreateView
import org.osmdroid.api.IMapController; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mRootView = inflater.inflate(R.layout.fragment_map, null, false);
ButterKnife.bind(this, mRootView);
IMapController mapController = mMap.getController();
mapController.setZoom(4);
GeoPoint startPoint = new GeoPoint(48.8583, 2.2944);
mapController.setCenter(startPoint);
return mRootView;
}
示例12: getCurrentLocation
import org.osmdroid.api.IMapController; //导入方法依赖的package包/类
/**
* Sets up the map to be pinpointed on the user's location.
*/
// see code attribution
private void getCurrentLocation() {
if(ContextCompat.checkSelfPermission(activity,
Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(activity,
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
MY_PERMISSIONS_REQUEST_ACCESS_FINE_LOCATION);
} else {
lastLocation = LocationServices.FusedLocationApi.getLastLocation(googleApiClient);
if (lastLocation == null) {
lastLocation = new Location("");
lastLocation.setLatitude(0);
lastLocation.setLongitude(0);
}
latitude = lastLocation.getLatitude();
longitude = lastLocation.getLongitude();
MapView map = (MapView) findViewById(R.id.map);
GeoPoint startPoint = new GeoPoint(latitude,longitude);
IMapController mapController = map.getController();
mapController.setZoom(18);
if(locationPoint == null) {
mapController.setCenter(startPoint);
}
MapEventsOverlay mapEventsOverlay = new MapEventsOverlay(activity, (MapEventsReceiver) activity);
map.getOverlays().add(0, mapEventsOverlay);
}
}
示例13: onCreateView
import org.osmdroid.api.IMapController; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_osm, container, false);
mUnbinder = ButterKnife.bind(this, view);
GeoPoint startPoint = new GeoPoint(mLat, mLng);
mapView.setTileSource(TileSourceFactory.MAPNIK);
mapView.setBuiltInZoomControls(true);
mapView.setMultiTouchControls(true);
mapView.setMaxZoomLevel(17);
//create the second one
final MapTileProviderBasic ofmTileProvider = new MapTileProviderBasic(getContext());
final ITileSource ofmTileSource = new XYTileSource("OpenFireMap", 10, 17, 256, ".png",
new String[]{"http://openfiremap.org/hytiles/"});
ofmTileProvider.setTileSource(ofmTileSource);
final TilesOverlay ofmTilesOverlay = new TilesOverlay(ofmTileProvider, getContext());
ofmTilesOverlay.setLoadingBackgroundColor(Color.TRANSPARENT);
mapView.getOverlays().add(ofmTilesOverlay);
//Alarm Marker
Marker startMarker = new Marker(mapView);
startMarker.setPosition(startPoint);
startMarker.setTitle(getString(R.string.operation_base));
startMarker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
mapView.getOverlays().add(startMarker);
IMapController mapController = mapView.getController();
mapController.setZoom(startZoomLevel);
mapController.setCenter(startPoint);
return view;
}
示例14: setLocation
import org.osmdroid.api.IMapController; //导入方法依赖的package包/类
public void setLocation(Location location) {
IMapController mapController = mMapView.getController();
mapController.setZoom(16);
GeoPoint gPoint = new GeoPoint(location.getLatCoord(), location.getLongCoord());
mapController.setCenter(gPoint);
mMarkerItem = new OverlayItem(location.getName(), location.getVegan().toString(), gPoint);
Drawable marker = getResources().getDrawable(R.mipmap.ic_map_pin_red);
mMarkerItem.setMarker(marker);
mLocationOverlay.addItem(mMarkerItem);
}
示例15: drawCurrentLocation
import org.osmdroid.api.IMapController; //导入方法依赖的package包/类
private void drawCurrentLocation(Location location) {
IMapController mapController = map.getController();
// This starts the map at the desired point
userLocation = new GeoPoint(location);
if (!isUserLocatedOnce) {
mapController.setCenter(userLocation);
}
// Now we add a marker using osmBonusPack
userLocationMarker.setPosition(userLocation);
userLocationMarker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
map.getOverlays().add(userLocationMarker);
// And we have to use this to refresh the map
// map.invalidate();
// We can change some properties of the marker (don't forget to refresh the map !!)
userLocationMarker.setInfoWindow(new CustomInfoWindow(map));
Drawable icon = null;
if (getActivity() != null) {
icon = ContextCompat.getDrawable(getActivity(), eu.wikijourney.wikijourney.R.drawable.ic_place);
}
try {
userLocationMarker.setIcon(icon);
userLocationMarker.setTitle(getString(eu.wikijourney.wikijourney.R.string.you_are_here));
map.invalidate();
} catch (Exception e) {
Log.e(LOG_ERROR, "drawCurrentLocation: " + e.getMessage(), e);
e.printStackTrace();
}
}