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


Java Marker.setIcon方法代码示例

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


在下文中一共展示了Marker.setIcon方法的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: 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

示例8: 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

示例9: 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

示例10: 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

示例11: addOverlays

import org.osmdroid.views.overlay.Marker; //导入方法依赖的package包/类
protected void addOverlays() {
    super.addOverlays();

    mMapView.setTilesScaledToDpi(true);
    mMapView.getController().setZoom(3);

    cm = (ConnectivityManager) getActivity().getSystemService(Context.CONNECTIVITY_SERVICE);

    image = getResources().getDrawable(R.drawable.sfppt);
    icon =getResources().getDrawable(R.drawable.sfppt_small);
    //icon_old=getResources().getDrawable(R.drawable.sfppt_small);
    //icon_old.setAlpha(77);

    marker = new Marker(mMapView);
    marker.setImage(image);
    marker.setIcon(icon);
    marker.setTitle("International Space Station");


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

示例12: 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

示例13: myLocation

import org.osmdroid.views.overlay.Marker; //导入方法依赖的package包/类
public static Marker myLocation(Context context, MapView map, double latitude, double longitude) {
    if (map == null || context == null) return null;
    Marker marker = new Marker(map);
    marker.setPosition(new GeoPoint(latitude, longitude));
    marker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
    marker.setIcon(context.getResources().getDrawable(R.drawable.ic_gps_location));
    marker.setInfoWindow(null);
    map.getOverlays().add(marker);
    map.invalidate();
    return marker;
}
 
开发者ID:CityZenApp,项目名称:Android-Development,代码行数:12,代码来源:MapUtils.java

示例14: 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());

    final InfoWindow infoWindow = (cluster.getSize() > 0) ? cluster.getItem(0).getInfoWindow() : null;
    m.setInfoWindow(infoWindow);
    m.setAnchor(mAnchorU, mAnchorV);

    final BitmapDrawable icon = getClusterMarkerIcon("" + cluster.getSize(), mapView);
    m.setIcon(icon);

    setRadius(48);

    return m;
}
 
开发者ID:k3b,项目名称:LocationMapViewer,代码行数:16,代码来源:RadiusMarkerClustererWithInfo.java

示例15: createMarker

import org.osmdroid.views.overlay.Marker; //导入方法依赖的package包/类
private Marker createMarker(MapView map, IGeoPointInfo aGeoPoint) {
    // final OverlayItem overlayItem = new OverlayItem(aGeoPoint.getId(), aGeoPoint.getName(), aGeoPoint.getDescription(), toOsmGeoPoint(aGeoPoint));
    // items.add(overlayItem);

    Marker poiMarker = new Marker(map);
    poiMarker.setTitle(aGeoPoint.getName());
    final String description = aGeoPoint.getDescription();
    poiMarker.setSnippet(description);
    poiMarker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
    poiMarker.setPosition(toOsmGeoPoint(aGeoPoint));

    if (BookmarkUtil.isNotEmpty(description) || BookmarkUtil.isNotEmpty(aGeoPoint.getLink()) || BookmarkUtil.isNotEmpty(aGeoPoint.getName())) {
        poiMarker.setIcon(mPoiIconWithData);
        // 7.
        poiMarker.setInfoWindow(new GeoPointMarkerInfoWindow(map));
    } else {
        poiMarker.setIcon(mPoiIconWithoutData);
        poiMarker.setInfoWindow(null);
    }
    /*
    if (poi.mThumbnail != null){
        poiMarker.setImage(new BitmapDrawable(poi.mThumbnail));
    }*/

    poiMarker.setRelatedObject(aGeoPoint);

    return poiMarker;
}
 
开发者ID:k3b,项目名称:LocationMapViewer,代码行数:29,代码来源:LocationMapViewer.java


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