Code example for Marker

Methods: setPosition, setSnippet, setTitle

0
    } 
 
    public void setMarker(Marker marker) {
        this.marker = marker;
        // We'll set marker settings here.. 
        marker.setTitle(screenName);
    } 
 
    /** 
     * Removes old polyline and makes another and adds it to the provided map. 
     * This is the only way to edit it. 
     * MUST BE CALLED FROM UI THREAD! 
     * @param map Map to add polyline to. 
     */ 
    public void makePolyline(GoogleMap map) {
        removePolyline(); 
        polyline = map.addPolyline(polylineOptions);
    } 
 
    /** 
     * Updates the marker to use last position and timestamp 
     * MUST BE CALLED FROM UI THREAD! 
     */ 
    public void updateMarker(GoogleMap map) {
        if(positions.size()==0) return;
        Coordinate pos = getPosition();
        if(marker == null) {
            BitmapDescriptor bitmap = BitmapDescriptorFactory.fromResource(icon);
 
            setMarker(map.addMarker(
                    new MarkerOptions()
                            .position(pos.getLatLng())
                            .anchor(0.5f, 0.5f) 
                            .icon(bitmap)));
        } 
        //Move our marker 
        marker.setPosition(pos.getLatLng());
 
        //Add some text to the onClick bubble to show how long it is since this user provided a coordinate. 
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm:ss");
        String time = simpleDateFormat.format(new Date(pos.getTimestamp()));
        marker.setSnippet("Last seen: "+time);
    } 
 
    /** 
     * Removes the polyline for this user, is set. 
     */