当前位置: 首页>>代码示例>>Java>>正文


Java GeoPoint类代码示例

本文整理汇总了Java中org.osmdroid.util.GeoPoint的典型用法代码示例。如果您正苦于以下问题:Java GeoPoint类的具体用法?Java GeoPoint怎么用?Java GeoPoint使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


GeoPoint类属于org.osmdroid.util包,在下文中一共展示了GeoPoint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addMarker

import org.osmdroid.util.GeoPoint; //导入依赖的package包/类
public static void addMarker(Context context, MapView map, Element element) {
    Marker marker = new Marker(map);
    marker.setPosition(new GeoPoint(element.lat, element.lon));
    marker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
    map.getOverlays().add(marker);
    map.invalidate();
    marker.setIcon(context.getResources().getDrawable(R.drawable.ic_location));

    marker.setTitle(String.valueOf(""));
    for (Map.Entry<String, String> tag : element.tags.entrySet()) {
        if (tag.getKey().equals("name")) {
            marker.setTitle(String.valueOf(tag.getValue()));
            break;
        }
    }
    if (marker.getTitle().equals(""))
        marker.setTitle(String.valueOf(element.id));

}
 
开发者ID:CityZenApp,项目名称:Android-Development,代码行数:20,代码来源:MapUtils.java

示例2: initMap

import org.osmdroid.util.GeoPoint; //导入依赖的package包/类
/**
 * Initialize the map configurations such as MapCamera, zoom values
 * and interface aspects.
 */
private void initMap(){
    // Map camera configuration
    GeoPoint startCameraPoint = new GeoPoint
            (defaultPlace.getLatitude(), defaultPlace.getLongitude());
    mapCamera = mapView.getController();
    mapCamera.setZoom(DEFAULT_ZOOM);
    mapCamera.animateTo(startCameraPoint);

    // Map configuration
    mapView.setTilesScaledToDpi(true);
    mapView.setTileSource(TileSourceFactory.DEFAULT_TILE_SOURCE);
    mapView.setBuiltInZoomControls(false);
    mapView.setMinZoomLevel(MIN_ZOOM);
    mapView.setMaxZoomLevel(MAX_ZOOM);
    mapView.setMultiTouchControls(true);
    mapView.setUseDataConnection(true);
    // Limits the map area to the region set
    mapView.setScrollableAreaLimitDouble(mapRegion);
    mCopyrightOverlay = new CopyrightOverlay(context);
    mapView.addOverlay(mCopyrightOverlay, OverlayTags.COPYRIGHT);
}
 
开发者ID:smartufpa,项目名称:SmartUFPA,代码行数:26,代码来源:MapFragment.java

示例3: GetBoundingBox

import org.osmdroid.util.GeoPoint; //导入依赖的package包/类
public static ArrayList<GeoPoint> GetBoundingBox(GeoPoint point, double halfSideInKm)
{
    ArrayList<GeoPoint> list = new ArrayList<GeoPoint>();
    // Bounding box surrounding the point at given coordinates,
    // assuming local approximation of Earth surface as a sphere
    // of radius given by WGS84
    double lat = Deg2rad(point.getLatitude());
    double lon = Deg2rad(point.getLongitude());
    double halfSide = 1000 * halfSideInKm;

    // Radius of Earth at given latitude
    double radius = WGS84EarthRadius(lat);
    // Radius of the parallel at given latitude
    double pradius = radius * Math.cos(lat);

    double latMin = lat - halfSide / radius;
    double latMax = lat + halfSide / radius;
    double lonMin = lon - halfSide / pradius;
    double lonMax = lon + halfSide / pradius;
        GeoPoint first = new GeoPoint(Rad2deg(latMin),Rad2deg(lonMin));
        GeoPoint second = new GeoPoint(Rad2deg(latMax),Rad2deg(lonMax));
    list.add(first);
    list.add(second);
    return  list;
}
 
开发者ID:flbbr,项目名称:Run2Stop,代码行数:26,代码来源:Calculator.java

示例4: mapSetup

import org.osmdroid.util.GeoPoint; //导入依赖的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);
}
 
开发者ID:CityZenApp,项目名称:Android-Development,代码行数:26,代码来源:CreatePoiFragment.java

示例5: singleTapConfirmedHelper

import org.osmdroid.util.GeoPoint; //导入依赖的package包/类
/*****************************************Map event listeners****************************************************/
@Override
public boolean singleTapConfirmedHelper(GeoPoint p) {
    if (addPoiMarker) {
        if (createPoiMarker == null)
            createPoiMarker = MapUtils.addMarker(getActivity(), map, p);
        else {//move to location
            if (createPoiMarker.isInfoWindowShown())
                createPoiMarker.closeInfoWindow();
            createPoiMarker.setPosition(p);
        }
        mapPoiCreationFormContainer.setVisibility(View.VISIBLE);
    } else
        getPoiAtLocation(p.getLatitude(), p.getLongitude());
    return true;
}
 
开发者ID:CityZenApp,项目名称:Android-Development,代码行数:17,代码来源:MapFragment.java

示例6: longPressHelper

import org.osmdroid.util.GeoPoint; //导入依赖的package包/类
@Override
public boolean longPressHelper(GeoPoint p) {
    disableCreatePoi();//disable poi creation if it is enabled
    DeviceLocationData location = ((MainActivity) getActivity()).getLastKnownLocation();
    if (location != null) {
        //clear existingRoute
        if (existingRoute != null) {
            map.getOverlays().remove(existingRoute);
            killRouteTimer();//kill this route re-render timer
        }
        //clear routeDestinationMarker
        if (routeDestinationMarker != null)
            map.getOverlays().remove(routeDestinationMarker);
        //clear data from MainActivity
        ((MainActivity) getActivity()).clearRoute();

        createRoute(location.getLatitude(), location.getLongitude(), p.getLatitude(), p.getLongitude());
    }
    return false;
}
 
开发者ID:CityZenApp,项目名称:Android-Development,代码行数:21,代码来源:MapFragment.java

示例7: setupMapPreview

import org.osmdroid.util.GeoPoint; //导入依赖的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);
}
 
开发者ID:CityZenApp,项目名称:Android-Development,代码行数:23,代码来源:PoiDetailsFragment.java

示例8: mapSetup

import org.osmdroid.util.GeoPoint; //导入依赖的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());
}
 
开发者ID:CityZenApp,项目名称:Android-Development,代码行数:20,代码来源:EditPoiFragment.java

示例9: configMap

import org.osmdroid.util.GeoPoint; //导入依赖的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);
}
 
开发者ID:DecentralizedAmateurPagingNetwork,项目名称:DAPNETApp,代码行数:19,代码来源:MapFragment.java

示例10: startLocationTracking

import org.osmdroid.util.GeoPoint; //导入依赖的package包/类
private synchronized void startLocationTracking()
{
    String[] requestedPermissions = new String[]
    {
            Manifest.permission.ACCESS_FINE_LOCATION,
            Manifest.permission.ACCESS_COARSE_LOCATION
    };

    if (!PermissionAndConnectionChecker.checkForPermissions(this, requestedPermissions,
            PermissionAndConnectionChecker.LocationRequestCode)) {
        return;
    }

    askToEnableGps();
    enableMyLocation();

    mLocationListener = new IObserver<GeoPoint>() {
        @Override
        public void notify(GeoPoint location) {
            locationChanged(location);
        }
    };
    LocationService.LocationChanged.subscribe(mLocationListener);

    sendCommandToLocationService(TrackerCommand.Start);
}
 
开发者ID:LenaShervarly,项目名称:TreasureHunting,代码行数:27,代码来源:MapsActivity.java

示例11: enableMyLocation

import org.osmdroid.util.GeoPoint; //导入依赖的package包/类
private void enableMyLocation() {
    if (mLocationOverlay != null)
        return;

    mLocationOverlay = MapHelper.addLocationOverlay(this, mMap);
    if (mLocationOverlay == null)
        return;

    FloatingActionButton btCenterMap = (FloatingActionButton) findViewById(R.id.button_center_map);
    mLocationOverlay.setDrawAccuracyEnabled(true);
    btCenterMap.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            GeoPoint myPosition = mLocationOverlay.getMyLocation();
            if (myPosition != null)
                mMap.getController().animateTo(myPosition);
        }
    });
}
 
开发者ID:LenaShervarly,项目名称:TreasureHunting,代码行数:20,代码来源:MapsActivity.java

示例12: getResourceToPlay

import org.osmdroid.util.GeoPoint; //导入依赖的package包/类
public AudioPoint getResourceToPlay(GeoPoint position, Vector2 direction) {
    float min = Integer.MAX_VALUE;
    AudioPoint closestPoint = null;

    cleanUpBanned(position);

    for (AudioPoint point : excursion.getRoute().audioPoints()) {
        if (excursion.getRoute().isAudioPointPassed(point.Number))
            continue;

        if (banned.contains(point))
            continue;

        float distance = LocationHelper.GetDistance(position, point.Position);
        if (distance < min && distance <= point.Radius)
        {
                min = distance;
                closestPoint = point;
        }
    }

    if (closestPoint == null)
        return null;

    return closestPoint;
}
 
开发者ID:LenaShervarly,项目名称:TreasureHunting,代码行数:27,代码来源:AudioPlaybackController.java

示例13: generateDirections

import org.osmdroid.util.GeoPoint; //导入依赖的package包/类
public void generateDirections() {
    if (_audioPoints.size() == 0)
        return;

    int audioPointIndex = 0;
    for(int i = 0; i < _geoPoints.size() - 1; i++) {

        GeoPoint current = _geoPoints.get(i).Position;
        GeoPoint next = _geoPoints.get(i + 1).Position;
        AudioPoint audioPoint = _audioPoints.get(audioPointIndex);

        while (current.distanceTo(next) > current.distanceTo(audioPoint.Position))
        {
            audioPoint.Direction = new Vector2(current, next).normalize();
            if (++audioPointIndex == _audioPoints.size())
                return;

            audioPoint = _audioPoints.get(audioPointIndex);
        }
    }
}
 
开发者ID:LenaShervarly,项目名称:TreasureHunting,代码行数:22,代码来源:Route.java

示例14: putMarker

import org.osmdroid.util.GeoPoint; //导入依赖的package包/类
public static Marker putMarker(Context context, MapView map, GeoPoint position, int resourceId,
    float horizontalAnchor, float verticalAnchor, boolean isDraggable)
{
    Marker marker = new Marker(map);
    marker.setPosition(position);
    marker.setAnchor(horizontalAnchor, verticalAnchor);
    marker.setDraggable(isDraggable);

    setMarkerIconFromResource(context, resourceId, marker);

    map.getOverlays().add(marker);
    map.invalidate();

    return marker;
}
 
开发者ID:LenaShervarly,项目名称:TreasureHunting,代码行数:16,代码来源:MapHelper.java

示例15: drawRoute

import org.osmdroid.util.GeoPoint; //导入依赖的package包/类
public static void drawRoute(Context context, MapView map, List<Point> points) {
    Polyline line = new Polyline(context);

    line.setSubDescription(Polyline.class.getCanonicalName());
    line.setWidth(15f);
    line.setColor(ContextCompat.getColor(context, R.color.orange_partially_transparent));

    List<GeoPoint> geoPoints = new ArrayList<>();

    for(Point point : points) {

        geoPoints.add(point.Position);
    }

    line.setPoints(geoPoints);
    line.setGeodesic(true);
    map.getOverlayManager().add(line);
}
 
开发者ID:LenaShervarly,项目名称:TreasureHunting,代码行数:19,代码来源:MapHelper.java


注:本文中的org.osmdroid.util.GeoPoint类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。