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


Java Marker.setPosition方法代码示例

本文整理汇总了Java中org.osmdroid.views.overlay.Marker.setPosition方法的典型用法代码示例。如果您正苦于以下问题:Java Marker.setPosition方法的具体用法?Java Marker.setPosition怎么用?Java Marker.setPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.osmdroid.views.overlay.Marker的用法示例。


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

示例1: addMarker

import org.osmdroid.views.overlay.Marker; //导入方法依赖的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: setMarkers

import org.osmdroid.views.overlay.Marker; //导入方法依赖的package包/类
/**
 * Given the request the user is viewing, set the map according to the start and end locations of the trip.
 */
private void setMarkers() {
    Marker startMarker = new Marker(map);
    startMarker.setIcon(ResourcesCompat.getDrawable(getResources(), R.drawable.ic_start_marker, null));
    Marker endMarker = new Marker(map);
    endMarker.setIcon(ResourcesCompat.getDrawable(getResources(), R.drawable.ic_end_marker, null));

    startMarker.setPosition(startPoint);
    startMarker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
    startMarker.setTitle("START:\n" + request.getStart().getAddress());
    startMarker.setInfoWindow(new BasicInfoWindow(org.osmdroid.bonuspack.R.layout.bonuspack_bubble, map));
    endMarker.setPosition(endPoint);
    endMarker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
    endMarker.setTitle("END:\n" + request.getEnd().getAddress());
    endMarker.setInfoWindow(new BasicInfoWindow(org.osmdroid.bonuspack.R.layout.bonuspack_bubble, map));

    map.getOverlays().add(startMarker);
    map.getOverlays().add(endMarker);
    map.invalidate();
}
 
开发者ID:CMPUT301F16T01,项目名称:Carrier,代码行数:23,代码来源:DriverViewRequestActivity.java

示例3: setMarkers

import org.osmdroid.views.overlay.Marker; //导入方法依赖的package包/类
/**
 * Set the start and end markers based on the exact positions the user gave for them
 */
private void setMarkers() {
    // set the map
    Marker startMarker = new Marker(map);
    startMarker.setIcon(ResourcesCompat.getDrawable(getResources(), R.drawable.ic_start_marker, null));
    Marker endMarker = new Marker(map);
    endMarker.setIcon(ResourcesCompat.getDrawable(getResources(), R.drawable.ic_end_marker, null));

    startMarker.setPosition(startPoint);
    startMarker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
    startMarker.setTitle("START:\n" + start.getAddress());
    startMarker.setInfoWindow(new BasicInfoWindow(org.osmdroid.bonuspack.R.layout.bonuspack_bubble, map));
    endMarker.setPosition(endPoint);
    endMarker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
    endMarker.setTitle("END:\n" + end.getAddress());
    endMarker.setInfoWindow(new BasicInfoWindow(org.osmdroid.bonuspack.R.layout.bonuspack_bubble, map));

    map.getOverlays().add(startMarker);
    map.getOverlays().add(endMarker);
    map.invalidate();
}
 
开发者ID:CMPUT301F16T01,项目名称:Carrier,代码行数:24,代码来源:ViewLocationsActivity.java

示例4: setMarkers

import org.osmdroid.views.overlay.Marker; //导入方法依赖的package包/类
/**
 * Given the request passed in by the user, set the map according to the start and end locations
 */
private void setMarkers() {
    Marker startMarker = new Marker(map);
    startMarker.setIcon(ResourcesCompat.getDrawable(getResources(), R.drawable.ic_start_marker, null));
    Marker endMarker = new Marker(map);
    endMarker.setIcon(ResourcesCompat.getDrawable(getResources(), R.drawable.ic_end_marker, null));

    startMarker.setPosition(startPoint);
    startMarker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
    startMarker.setTitle("START:\n" + request.getStart().getAddress());
    startMarker.setInfoWindow(new BasicInfoWindow(org.osmdroid.bonuspack.R.layout.bonuspack_bubble, map));
    endMarker.setPosition(endPoint);
    endMarker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
    endMarker.setTitle("END:\n" + request.getEnd().getAddress());
    endMarker.setInfoWindow(new BasicInfoWindow(org.osmdroid.bonuspack.R.layout.bonuspack_bubble, map));

    map.getOverlays().add(startMarker);
    map.getOverlays().add(endMarker);
    map.invalidate();
}
 
开发者ID:CMPUT301F16T01,项目名称:Carrier,代码行数:23,代码来源:RiderRequestActivity.java

示例5: createCustomMarker

import org.osmdroid.views.overlay.Marker; //导入方法依赖的package包/类
public Marker createCustomMarker(MapView mapView, Drawable markerIcon, GeoPoint location, @Nullable Marker.OnMarkerClickListener clickListener){

        Marker poiMarker = new Marker(mapView);
        poiMarker.setAnchor(0.5f,1);
        poiMarker.setPosition(location);
        if(markerIcon == null){
            throw new NullMarkerDrawableException("You must choose a drawable asset for your Marker");
        }

        poiMarker.setIcon(markerIcon);

        if(clickListener != null){
            poiMarker.setOnMarkerClickListener(clickListener);
        }
        return poiMarker;

    }
 
开发者ID:smartufpa,项目名称:SmartUFPA,代码行数:18,代码来源:MapUtils.java

示例6: getLocation

import org.osmdroid.views.overlay.Marker; //导入方法依赖的package包/类
/**
 *  Gets location from ChooseLocationActivity, prints it, and puts it on the map
 */
public void getLocation() {
    Intent intent = getIntent();
    Gson gson = new Gson();

    map.getOverlays().clear();
    if (intent.getStringExtra("keyword") != null) {
        keyLocation = new Location("");
        keyLocation = gson.fromJson(intent.getStringExtra("keyword"), keyLocation.getClass());
    }
    if (keyLocation == null) {
        keywords.setText("");
    }
    if (keyLocation != null) {
        startLocation.setText(keyLocation.getAddress());
        Marker locMarker = new Marker(map);
        locMarker.setPosition(keyLocation.getGeoLocation());
        locMarker.setTitle(keyLocation.getAddress());
        locMarker.setIcon(getResources().getDrawable(R.drawable.person));
        locMarker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
        map.getOverlays().add(locMarker);
    }
}
 
开发者ID:CMPUT301F16T19,项目名称:SeekARide,代码行数:26,代码来源:SearchRequestsActivity.java

示例7: add

import org.osmdroid.views.overlay.Marker; //导入方法依赖的package包/类
protected void add(List<GeoPoint> points, int color) {
    Polyline polyline = new Polyline();
    polyline.setColor(color);
    polyline.setPoints(points);

    if (routes.isEmpty()){
        initMarker.setPosition(points.get(0));
    } else {
        Marker marker = getInnerMarker();
        marker.setPosition(points.get(0));
        //markers.add(marker);
    }
    this.routes.add(polyline);
    endMarker.setPosition(points.get(points.size()-1));
    hideMarkers = false;

    this.setDirty(true);
}
 
开发者ID:InspectorIncognito,项目名称:androidApp,代码行数:19,代码来源:PolylineLayer.java

示例8: putRoadNodes

import org.osmdroid.views.overlay.Marker; //导入方法依赖的package包/类
private void putRoadNodes(Road road){
	mRoadNodeMarkers.getItems().clear();
	Drawable icon = ResourcesCompat.getDrawable(getResources(), R.drawable.marker_node, null);
	int n = road.mNodes.size();
	MarkerInfoWindow infoWindow = new MarkerInfoWindow(org.osmdroid.bonuspack.R.layout.bonuspack_bubble, map);
	TypedArray iconIds = getResources().obtainTypedArray(R.array.direction_icons);
   	for (int i=0; i<n; i++){
   		RoadNode node = road.mNodes.get(i);
   		String instructions = (node.mInstructions==null ? "" : node.mInstructions);
   		Marker nodeMarker = new Marker(map);
   		nodeMarker.setTitle(getString(R.string.step)+ " " + (i+1));
   		nodeMarker.setSnippet(instructions);
		nodeMarker.setSubDescription(Road.getLengthDurationText(this, node.mLength, node.mDuration));
		nodeMarker.setPosition(node.mLocation);
   		nodeMarker.setIcon(icon);
		nodeMarker.setInfoWindow(infoWindow); //use a shared infowindow.
		int iconId = iconIds.getResourceId(node.mManeuverType, R.drawable.ic_empty);
   		if (iconId != R.drawable.ic_empty){
			Drawable image = ResourcesCompat.getDrawable(getResources(), iconId, null);
			nodeMarker.setImage(image);
   		}
   		mRoadNodeMarkers.add(nodeMarker);
   	}
   	iconIds.recycle();
}
 
开发者ID:MKergall,项目名称:osmbonuspack,代码行数:26,代码来源:MapActivity.java

示例9: buildClusterMarker

import org.osmdroid.views.overlay.Marker; //导入方法依赖的package包/类
@Override public Marker buildClusterMarker(StaticCluster cluster, MapView mapView) {
    Marker m = new Marker(mapView);
    m.setPosition(cluster.getPosition());
    m.setInfoWindow(null);
    m.setAnchor(mAnchorU, mAnchorV);

    Bitmap finalIcon = Bitmap.createBitmap(mClusterIcon.getWidth(), mClusterIcon.getHeight(), mClusterIcon.getConfig());
    Canvas iconCanvas = new Canvas(finalIcon);
    iconCanvas.drawBitmap(mClusterIcon, 0, 0, null);
    String text = "" + cluster.getSize();
    int textHeight = (int) (mTextPaint.descent() + mTextPaint.ascent());
    iconCanvas.drawText(text,
            mTextAnchorU * finalIcon.getWidth(),
            mTextAnchorV * finalIcon.getHeight() - textHeight / 2,
            mTextPaint);
    m.setIcon(new BitmapDrawable(mapView.getContext().getResources(), finalIcon));

    return m;
}
 
开发者ID:MKergall,项目名称:osmbonuspack,代码行数:20,代码来源:RadiusMarkerClusterer.java

示例10: buildClusterMarker

import org.osmdroid.views.overlay.Marker; //导入方法依赖的package包/类
/** Build the marker for a cluster. 
 * Uses the cluster icon, and displays inside the number of markers it contains. <br/>
 * In the standard Google coordinate system for Marker icons: <br/>
 * - The cluster icon is anchored at mAnchorU, mAnchorV. <br/>
 * - The text showing the number of markers is anchored at mTextAnchorU, mTextAnchorV. 
 * This text is centered horizontally and vertically. */
@Override public Marker buildClusterMarker(StaticCluster cluster, MapView mapView){
	Marker m = new Marker(mapView);
	m.setPosition(cluster.getPosition());
	m.setInfoWindow(null);
	m.setAnchor(mAnchorU, mAnchorV);
	Bitmap finalIcon = Bitmap.createBitmap(mClusterIcon.getWidth(), mClusterIcon.getHeight(), mClusterIcon.getConfig());
	Canvas iconCanvas = new Canvas(finalIcon);
	iconCanvas.drawBitmap(mClusterIcon, 0, 0, null);
	String text = ""+cluster.getSize();
    int textHeight = (int) (mTextPaint.descent() + mTextPaint.ascent());
	iconCanvas.drawText(text, 
			mTextAnchorU*finalIcon.getWidth(), 
			mTextAnchorV*finalIcon.getHeight() - textHeight/2, 
			mTextPaint);
	m.setIcon(new BitmapDrawable(mapView.getContext().getResources(), finalIcon));
	return m;
}
 
开发者ID:MKergall,项目名称:osmbonuspack,代码行数:24,代码来源:GridMarkerClusterer.java

示例11: buildOverlay

import org.osmdroid.views.overlay.Marker; //导入方法依赖的package包/类
/** Build the corresponding Marker overlay */	
@Override public Overlay buildOverlay(MapView map, Style defaultStyle, Styler styler, KmlPlacemark kmlPlacemark, 
		KmlDocument kmlDocument){
	Marker marker = new Marker(map);
	marker.setTitle(kmlPlacemark.mName);
	marker.setSnippet(kmlPlacemark.mDescription);
	marker.setSubDescription(kmlPlacemark.getExtendedDataAsText());
	marker.setPosition(getPosition());
	//keep the link from the marker to the KML feature:
	marker.setRelatedObject(this);
	if (styler == null){
		applyDefaultStyling(marker, defaultStyle, kmlPlacemark, kmlDocument, map);
	} else
		styler.onPoint(marker, kmlPlacemark, this);
	return marker;
}
 
开发者ID:MKergall,项目名称:osmbonuspack,代码行数:17,代码来源:KmlPoint.java

示例12: addIcons

import org.osmdroid.views.overlay.Marker; //导入方法依赖的package包/类
private void addIcons(int count) {
     for (int i = 0; i < count; i++) {
          double random_lon = (Math.random() * 360) - 180;
          double random_lat = (Math.random() * 180) - 90;
          Marker m = new Marker(mMapView);
          m.setPosition(new GeoPoint(random_lat, random_lon));
          int index = (int) (Math.random() * (icons.size()));
          if (index == icons.size()) {
               index--;
          }
          m.setSnippet("A random point");
          m.setSubDescription("location: " + random_lat + "," + random_lon);
          m.setIcon(icons.get(index));
          mMapView.getOverlayManager().add(m);
     }

     mMapView.invalidate();
     Toast.makeText(getActivity(), count + " icons added! Current size: " + mMapView.getOverlayManager().size(), Toast.LENGTH_SHORT).show();

}
 
开发者ID:osmdroid,项目名称:osmdroid,代码行数:21,代码来源:SampleMilitaryIconsMarker.java

示例13: addOverlays

import org.osmdroid.views.overlay.Marker; //导入方法依赖的package包/类
@Override
protected void addOverlays() {
    super.addOverlays();
    LatLonGridlineOverlay.setDefaults();
    mMapView.getController().setCenter(new GeoPoint(0d, 0d));
    mMapView.getController().setZoom(5);
    mMapView.setTilesScaledToDpi(true);
    mMapView.setMapListener(this);
    mMapView.getController().setZoom(3);

    marker = new Marker(mMapView);
    marker.setPosition(new GeoPoint(45d, -74d));

    updateGridlines();

}
 
开发者ID:osmdroid,项目名称:osmdroid,代码行数:17,代码来源:AnimatedMarkerTimer.java

示例14: onCreateView

import org.osmdroid.views.overlay.Marker; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {


    View root = inflater.inflate(R.layout.sample_cachemgr, container,false);
    setHasOptionsMenu(false);//prevent tile source changes
    mMapView = (MapView) root.findViewById(R.id.mapview);
    btnCache = (Button) root.findViewById(R.id.btnCache);
    btnCache.setOnClickListener(this);
    btnCache.setText("Start/Stop Animation");

    marker = new Marker(mMapView);
    marker.setTitle("An animated marker");
    marker.setPosition(new GeoPoint(0d,0d));
    mMapView.getOverlayManager().add(marker);



    return root;
}
 
开发者ID:osmdroid,项目名称:osmdroid,代码行数:21,代码来源:AnimatedMarkerTypeEvaluator.java

示例15: addLatLngToMap

import org.osmdroid.views.overlay.Marker; //导入方法依赖的package包/类
/**
 * Add a LatLng to the map
 *
 * @param map
 * @param latLng
 * @param options
 * @return
 */
public static Marker addLatLngToMap(MapView map, GeoPoint latLng,
                                    MarkerOptions options) {
    Marker m = new Marker(map);
    m.setPosition(latLng);
    if (options!=null) {
        if (options.getIcon()!=null){
            m.setIcon(options.getIcon());
        }
        m.setAlpha(options.getAlpha());
        m.setTitle(options.getTitle());
        m.setSubDescription(options.getSubdescription());
        m.setInfoWindow(new BasicInfoWindow(R.layout.bonuspack_bubble, map));
    }
    map.getOverlayManager().add(m);
    return m;
}
 
开发者ID:osmdroid,项目名称:osmdroid,代码行数:25,代码来源:OsmMapShapeConverter.java


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