Java Code Examples for com.google.android.gms.maps.model.MarkerOptions#title()

The following examples show how to use com.google.android.gms.maps.model.MarkerOptions#title() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GetNearbyPlacesData.java    From BloodBank with GNU General Public License v3.0 6 votes vote down vote up
private void showNearbyPlaces(List<HashMap<String, String>> nearbyplaces)
{
    for(int i=0; i<nearbyplaces.size(); i++)
    {
        MarkerOptions markerOptions = new MarkerOptions();
        HashMap<String, String> googlePlace = nearbyplaces.get(i);

        String PlaceName = googlePlace.get("place_name");
        String vicinity = googlePlace.get("vicinity");
        double lat = Double.parseDouble(googlePlace.get("lat"));
        double lng = Double.parseDouble(googlePlace.get("lng"));

        LatLng latLng = new LatLng(lat, lng);
        markerOptions.position(latLng);
        markerOptions.title(PlaceName+" "+vicinity);
        markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE));

        mMap.addMarker(markerOptions);
        mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
        mMap.animateCamera(CameraUpdateFactory.zoomBy(10));
    }
}
 
Example 2
Source File: GeoJsonPointStyle.java    From android-maps-utils with Apache License 2.0 6 votes vote down vote up
/**
 * Gets a new MarkerOptions object containing styles for the GeoJsonPoint
 *
 * @return new MarkerOptions object
 */
public MarkerOptions toMarkerOptions() {
    MarkerOptions markerOptions = new MarkerOptions();
    markerOptions.alpha(mMarkerOptions.getAlpha());
    markerOptions.anchor(mMarkerOptions.getAnchorU(), mMarkerOptions.getAnchorV());
    markerOptions.draggable(mMarkerOptions.isDraggable());
    markerOptions.flat(mMarkerOptions.isFlat());
    markerOptions.icon(mMarkerOptions.getIcon());
    markerOptions.infoWindowAnchor(mMarkerOptions.getInfoWindowAnchorU(),
            mMarkerOptions.getInfoWindowAnchorV());
    markerOptions.rotation(mMarkerOptions.getRotation());
    markerOptions.snippet(mMarkerOptions.getSnippet());
    markerOptions.title(mMarkerOptions.getTitle());
    markerOptions.visible(mMarkerOptions.isVisible());
    markerOptions.zIndex(mMarkerOptions.getZIndex());
    return markerOptions;
}
 
Example 3
Source File: MapWrapper.java    From osmdroid with Apache License 2.0 6 votes vote down vote up
@Override
public void addMarker(final Marker aMarker) {
	final MarkerOptions marker = new MarkerOptions();
	marker.position(new LatLng(aMarker.latitude, aMarker.longitude));
	if (!TextUtils.isEmpty(aMarker.title)) {
		marker.title(aMarker.title);
	}
	if (!TextUtils.isEmpty(aMarker.snippet)) {
		marker.snippet(aMarker.snippet);
	}
	if (aMarker.bitmap != null) {
		marker.icon(BitmapDescriptorFactory.fromBitmap(aMarker.bitmap));
	} else {
		if (aMarker.icon != 0) {
			marker.icon(BitmapDescriptorFactory.fromResource(aMarker.icon));
		}
	}
	if (aMarker.anchor == Marker.Anchor.CENTER) {
		marker.anchor(0.5f, 0.5f);
	}
	mGoogleMap.addMarker(marker);
}
 
Example 4
Source File: PTRMapFragment.java    From AndroidDemoProjects with Apache License 2.0 6 votes vote down vote up
public void addMarker( float color, LatLng latLng, String title ) {
	if( mMap == null )
		mMap = ( (SupportMapFragment) getFragmentManager()
				.findFragmentById( R.id.map ) )
				.getMap();

	if( latLng == null || mMap == null )
		return;

	MarkerOptions markerOptions = new MarkerOptions().position( latLng );
	if( !title.isEmpty() )
		markerOptions.title( title );

	if( color == 0 )
		color = BitmapDescriptorFactory.HUE_RED;

	markerOptions.icon( BitmapDescriptorFactory.defaultMarker( color ) );
	Marker marker = mMap.addMarker( markerOptions );
	if( !markerLocations.contains( marker ) )
		markerLocations.add( marker );

	marker.showInfoWindow();
}
 
Example 5
Source File: PlacesDisplayTask.java    From Crimson with Apache License 2.0 6 votes vote down vote up
@Override
protected void onPostExecute(List<HashMap<String, String>> list) {
    googleMap.clear();

        for (int i = 0; i < list.size(); i++) {
            MarkerOptions markerOptions = new MarkerOptions();
            HashMap<String, String> googlePlace = list.get(i);
            double lat = Double.parseDouble(googlePlace.get("lat"));
            double lng = Double.parseDouble(googlePlace.get("lng"));
            String placeName = googlePlace.get("place_name");
            //String vicinity = googlePlace.get("vicinity");
            LatLng latLng = new LatLng(lat, lng);
            markerOptions.position(latLng);
            markerOptions.title(placeName);
            markerOptions.icon(BitmapDescriptorFactory.fromResource(R.drawable.custom_marker));
            googleMap.addMarker(markerOptions);
        }
    }
 
Example 6
Source File: MarkerActivity.java    From Complete-Google-Map-API-Tutorial with Apache License 2.0 6 votes vote down vote up
private void addMarkersToMap()
{
	MarkerOptions options =new MarkerOptions();
	options.position(BRISBANE);
	options.title("brisbane");
	options.snippet("Population: 2,544,634");
	options.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE));
	options.draggable(true);
	CustomInfoWindowAdapter.brisbane=googleMap.addMarker(options);


	MarkerOptions options2 =new MarkerOptions();
	options2.position(ADELAIDE);
	options2.title("adelaide");
	options2.snippet("Population: 3,543,222");
	Drawable drawable=ContextCompat.getDrawable(getApplicationContext(),R.drawable.ic_person_pin_circle_black_24dp);
	options2.icon(convertDrawableToBitmap(drawable));
	options2.draggable(true);
	CustomInfoWindowAdapter.adelaide=googleMap.addMarker(options2);
}
 
Example 7
Source File: MapFragment.java    From Android-GoogleMaps-Part1 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void onMapClick(LatLng latLng) {

    MarkerOptions options = new MarkerOptions().position( latLng );
    options.title( getAddressFromLatLng( latLng ) );

    options.icon( BitmapDescriptorFactory.defaultMarker( ) );
    getMap().addMarker( options );
}
 
Example 8
Source File: LocationActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private void updatePlacesMarkers(ArrayList<TLRPC.TL_messageMediaVenue> places) {
    if (places == null) {
        return;
    }
    for (int a = 0, N = placeMarkers.size(); a < N; a++) {
        placeMarkers.get(a).marker.remove();
    }
    placeMarkers.clear();
    for (int a = 0, N = places.size(); a < N; a++) {
        TLRPC.TL_messageMediaVenue venue = places.get(a);
        try {
            MarkerOptions options = new MarkerOptions().position(new LatLng(venue.geo.lat, venue.geo._long));
            options.icon(BitmapDescriptorFactory.fromBitmap(createPlaceBitmap(a)));
            options.anchor(0.5f, 0.5f);
            options.title(venue.title);
            options.snippet(venue.address);
            VenueLocation venueLocation = new VenueLocation();
            venueLocation.num = a;
            venueLocation.marker = googleMap.addMarker(options);
            venueLocation.venue = venue;
            venueLocation.marker.setTag(venueLocation);
            placeMarkers.add(venueLocation);
        } catch (Exception e) {
            FileLog.e(e);
        }
    }
}
 
Example 9
Source File: ToastedMarkerOptionsChooser.java    From clusterkraf with Apache License 2.0 5 votes vote down vote up
@Override
public void choose(MarkerOptions markerOptions, ClusterPoint clusterPoint) {
	Context context = contextRef.get();
	if (context != null) {
		Resources res = context.getResources();
		boolean isCluster = clusterPoint.size() > 1;
		boolean hasTwoToasters = clusterPoint.containsInputPoint(twoToasters);
		BitmapDescriptor icon;
		String title;
		if (isCluster) {
			title = res.getQuantityString(R.plurals.count_points, clusterPoint.size(), clusterPoint.size());
			int clusterSize = clusterPoint.size();
			if (hasTwoToasters) {
				icon = BitmapDescriptorFactory.fromBitmap(getClusterBitmap(res, R.drawable.ic_map_pin_cluster_toaster, clusterSize));
				title = res.getString(R.string.including_two_toasters, title);
			} else {
				icon = BitmapDescriptorFactory.fromBitmap(getClusterBitmap(res, R.drawable.ic_map_pin_cluster, clusterSize));
				title = res.getQuantityString(R.plurals.count_points, clusterSize, clusterSize);
			}
		} else {
			MarkerData data = (MarkerData)clusterPoint.getPointAtOffset(0).getTag();
			if (hasTwoToasters) {
				icon = BitmapDescriptorFactory.fromResource(R.drawable.ic_map_pin_toaster);
				title = data.getLabel();
			} else {
				icon = BitmapDescriptorFactory.fromResource(R.drawable.ic_map_pin);
				title = res.getString(R.string.point_number_x, data.getLabel());
			}
		}
		markerOptions.icon(icon);
		markerOptions.title(title);
		markerOptions.anchor(0.5f, 1.0f);
	}
}
 
Example 10
Source File: MainActivity.java    From effective_android_sample with Apache License 2.0 5 votes vote down vote up
/**
 * 戦場1つを描画する
 */
private void drawField(Field field) {
    // マーカー定義
    MarkerOptions markerOptions = new MarkerOptions();
    markerOptions.title(field.getName()); // 名前を設定
    markerOptions.snippet(field.getMemo()); // 説明を設定
    markerOptions.position(calcCenter(field.getVertexes())); // マーカーの座標を設定(区画の中心を自動算出)
    markerOptions.icon(BitmapDescriptorFactory.defaultMarker(field.getColorHue())); // 色を設定

    // マップにマーカーを追加
    mGoogleMap.addMarker(markerOptions);

    // 区画を描画
    final LatLng[] vertexes = field.getVertexes();
    if (vertexes != null && vertexes.length > 3) {
        // ポリゴン定義
        PolygonOptions polygonOptions = new PolygonOptions();

        // RGBそれぞれの色を作成
        final int[] colorRgb = field.getColorRgb();
        int colorRed = colorRgb[0];
        int colorGreen = colorRgb[1];
        int colorBlue = colorRgb[2];

        // 区画の輪郭について設定
        polygonOptions.strokeColor(Color.argb(0x255, colorRed, colorGreen, colorBlue));
        polygonOptions.strokeWidth(5);

        // 区画の塗りつぶしについて設定
        polygonOptions.fillColor(Color.argb(0x40, colorRed, colorGreen, colorBlue));

        // 各頂点の座標を設定
        polygonOptions.add(vertexes); // LatLngでもLatLng[]でもOK

        // マップにポリゴンを追加
        mGoogleMap.addPolygon(polygonOptions);
    }
}
 
Example 11
Source File: MapFragment.java    From AndroidDemoProjects with Apache License 2.0 5 votes vote down vote up
@Override
public void onMapClick(LatLng latLng) {

    MarkerOptions options = new MarkerOptions().position( latLng );
    options.title( getAddressFromLatLng( latLng ) );

    options.icon( BitmapDescriptorFactory.defaultMarker( ) );
    getMap().addMarker( options );
}
 
Example 12
Source File: ShowLocationActivity.java    From ShareLocationPlugin with GNU General Public License v3.0 5 votes vote down vote up
private void markAndCenterOnLocation(LatLng location, String name) {
	this.mGoogleMap.clear();
	MarkerOptions options = new MarkerOptions();
	options.position(location);
	if (name != null) {
		options.title(name);
		this.mGoogleMap.addMarker(options).showInfoWindow();
	} else {
		this.mGoogleMap.addMarker(options);
	}
	this.mGoogleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(location, Config.DEFAULT_ZOOM));
}
 
Example 13
Source File: MapFragment.java    From Android-GoogleMaps-Part1 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void onMapLongClick(LatLng latLng) {
    MarkerOptions options = new MarkerOptions().position( latLng );
    options.title( getAddressFromLatLng(latLng) );

    options.icon( BitmapDescriptorFactory.fromBitmap(
            BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher ) ) );

    getMap().addMarker(options);
}
 
Example 14
Source File: MainActivity.java    From ExamplesAndroid with Apache License 2.0 5 votes vote down vote up
@Override
protected void onBeforeClusterItemRendered(MyItem item, MarkerOptions markerOptions) {

    BitmapDescriptor icon = BitmapDescriptorFactory.fromResource(R.mipmap.davidhackro);
    markerOptions.icon(icon);
    markerOptions.snippet(item.getTitle());
    markerOptions.title(item.getSubtitle());
    markerOptions.position(item.getPosition());


    super.onBeforeClusterItemRendered(item, markerOptions);
}
 
Example 15
Source File: MapsActivity.java    From Self-Driving-Car with MIT License 5 votes vote down vote up
@Override
    public void onLocationChanged(Location location) {


        mLastLocation = location;
        if (mCurrLocationMarker != null) {
            mCurrLocationMarker.remove();
        }

        LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
        Data data = new Data();
        data.setCurrentLocation(latLng);
        Log.e("Location", String.valueOf(location.getAccuracy()));
        data.setAltitude(location.getAltitude());

        //Place current location marker
        if (toSetMarker) {

            MarkerOptions markerOptions = new MarkerOptions();
            markerOptions.position(latLng);
            markerOptions.title("Current Position");
            markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_ROSE));
            mCurrLocationMarker = mMap.addMarker(markerOptions);
            markerPoints.add(latLng);


            //move map camera
            mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
            mMap.animateCamera(CameraUpdateFactory.zoomTo(18));
        }
        toSetMarker = false;


//        //stop location updates
//        if (mGoogleApiClient != null) {
//            LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this);
//        }

    }
 
Example 16
Source File: MapsActivity.java    From Krishi-Seva with MIT License 5 votes vote down vote up
@Override
public void onLocationChanged(Location location) {
    Log.d("onLocationChanged", "entered");

    mLastLocation = location;
    if (mCurrLocationMarker != null) {
        mCurrLocationMarker.remove();
    }


    latitude = location.getLatitude();
    longitude = location.getLongitude();
    LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
    MarkerOptions markerOptions = new MarkerOptions();
    markerOptions.position(latLng);
    markerOptions.title("Current Position");
    markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_MAGENTA));
    mCurrLocationMarker = mMap.addMarker(markerOptions);

    mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
    mMap.animateCamera(CameraUpdateFactory.zoomTo(11));
    Toast.makeText(MapsActivity.this,"Navigate To Farmer For Product.", Toast.LENGTH_LONG).show();



    if (mGoogleApiClient != null) {
        LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this);
        Log.d("onLocationChanged", "Removing Location Updates");
    }
    Log.d("onLocationChanged", "Exit");

}
 
Example 17
Source File: ChatAttachAlertLocationLayout.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private void updatePlacesMarkers(ArrayList<TLRPC.TL_messageMediaVenue> places) {
    if (places == null) {
        return;
    }
    for (int a = 0, N = placeMarkers.size(); a < N; a++) {
        placeMarkers.get(a).marker.remove();
    }
    placeMarkers.clear();
    for (int a = 0, N = places.size(); a < N; a++) {
        TLRPC.TL_messageMediaVenue venue = places.get(a);
        try {
            MarkerOptions options = new MarkerOptions().position(new LatLng(venue.geo.lat, venue.geo._long));
            options.icon(BitmapDescriptorFactory.fromBitmap(createPlaceBitmap(a)));
            options.anchor(0.5f, 0.5f);
            options.title(venue.title);
            options.snippet(venue.address);
            VenueLocation venueLocation = new VenueLocation();
            venueLocation.num = a;
            venueLocation.marker = googleMap.addMarker(options);
            venueLocation.venue = venue;
            venueLocation.marker.setTag(venueLocation);
            placeMarkers.add(venueLocation);
        } catch (Exception e) {
            FileLog.e(e);
        }
    }
}
 
Example 18
Source File: MapActivity.java    From Bus-Tracking-Parent with GNU General Public License v3.0 5 votes vote down vote up
private void addMarker(LatLng location, String time) {
    if (mGoogleMap != null) {
        MarkerOptions mMarkerOption = new MarkerOptions();
        mMarkerOption.position(location);
        mMarkerOption.title("Bus is here");
        mMarkerOption.snippet(time);
        mMarkerOption.icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_directions_bus_black_24dp));
        removeMarker();
        mMarker = mGoogleMap.addMarker(mMarkerOption);
    }
}
 
Example 19
Source File: NearByHospitalActivity.java    From BloodBank with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onLocationChanged(Location location) {
    lastlocation = location;
    LatLng latLng = new LatLng(location.getLatitude() , location.getLongitude());
    MarkerOptions markerOptions = new MarkerOptions();
    markerOptions.position(latLng);
    markerOptions.title("Current Location");
    markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE));
    currentLocationmMarker = mMap.addMarker(markerOptions);
    mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
    mMap.animateCamera(CameraUpdateFactory.zoomBy(0));

}
 
Example 20
Source File: MapActivity.java    From Bus-Tracking-Parent with GNU General Public License v3.0 4 votes vote down vote up
private void forRecentRide() {
    // get details from intent
    String start_gps = getIntent().getStringExtra("start_gps");
    String end_gps = getIntent().getStringExtra("end_gps");
    String start_time = getIntent().getStringExtra("start_time");
    String end_time = getIntent().getStringExtra("end_time");
    String current_gps = getIntent().getStringExtra("current_gps");

    LatLong sGps = new LatLong(start_gps);
    LatLong eGps = new LatLong(end_gps);
    LatLong cGps = new LatLong(current_gps);
    if (sGps.isValid()) {
        start_time = DateTimeUtils.getTime(start_time);
        end_time = DateTimeUtils.getTime(end_time);
        MarkerOptions s_options = new MarkerOptions();
        s_options.position(new LatLng(sGps.getLat(), sGps.getLon()));
        s_options.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_ORANGE));
        s_options.title("Started :" + start_time);
        s_options.snippet(LocationHelper.getLocationName(this, sGps.getLat(), sGps.getLon()));
        addCustomMarker(s_options);
        if (eGps.isValid()) {
            // draw line
            //addLine(new LatLng(sGps.getLat(), sGps.getLat()), new LatLng(eGps.getLat(), eGps.getLon()));

            MarkerOptions e_options = new MarkerOptions();
            e_options.position(new LatLng(eGps.getLat(), eGps.getLon()));
            e_options.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN));
            e_options.title("Completed :" + end_time);
            e_options.snippet(LocationHelper.getLocationName(this, eGps.getLat(), eGps.getLon()));
            addCustomMarker(e_options);
        } else if (cGps.isValid()) {
            // draw line
            //addLine(new LatLng(cGps.getLat(), cGps.getLat()), new LatLng(sGps.getLat(), sGps.getLon()));

            MarkerOptions c_options = new MarkerOptions();
            c_options.position(new LatLng(cGps.getLat(), cGps.getLon()));
            c_options.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED));
            c_options.title("Incomplete ?");
            c_options.snippet(LocationHelper.getLocationName(this, cGps.getLat(), cGps.getLon()));
            addCustomMarker(c_options);
        }
    }
}