com.google.maps.android.ui.IconGenerator Java Examples

The following examples show how to use com.google.maps.android.ui.IconGenerator. 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: RealTimeLocationDisplayActivity.java    From NaviBee with GNU General Public License v3.0 5 votes vote down vote up
private void update(boolean timer) {
    if (googleMap == null) return;
    if (location != null) {
        long oneAgo = System.currentTimeMillis() - EXPIRE_TIME;
        if (lastUpdate.getTime() < oneAgo) {
            if (marker != null) {
                marker.remove();
            }
        } else {
            if (marker == null) {
                marker = googleMap.addMarker(new MarkerOptions().position(location));
                googleMap.moveCamera(CameraUpdateFactory.newLatLng(location));
                googleMap.moveCamera(CameraUpdateFactory.zoomTo(DEFAULT_ZOOM_LEVEL));
                marker.setIcon(BitmapDescriptorFactory.fromBitmap(new IconGenerator(this).makeIcon(userName)));
            } else {
                marker.setPosition(location);
            }


        }
    }

    if (timer && myLocation!=null) {
        // update my location
        Map<String, Object> data = new HashMap<>();
        data.put("latitude", myLocation.latitude);
        data.put("longitude", myLocation.longitude);
        data.put("time", Timestamp.now());

        FirebaseFirestore.getInstance()
                .collection("conversations")
                .document(conv.conversationId)
                .collection("realtimeLocations")
                .document(FirebaseAuth.getInstance().getUid()).set(data);
    }

}
 
Example #2
Source File: BarometerNetworkActivity.java    From PressureNet with GNU General Public License v3.0 5 votes vote down vote up
private void addIcon(IconGenerator iconFactory, String text, LatLng position) {
    MarkerOptions markerOptions = new MarkerOptions().
            icon(BitmapDescriptorFactory.fromBitmap(iconFactory.makeIcon(text))).
            position(position).
            anchor(iconFactory.getAnchorU(), iconFactory.getAnchorV());

    Marker addedTemp = mMap.addMarker(markerOptions);
    
    //log("added temp icon");
}
 
Example #3
Source File: IconGeneratorDemoActivity.java    From android-maps-utils with Apache License 2.0 5 votes vote down vote up
@Override
protected void startDemo(boolean isRestore) {
    if (!isRestore) {
        getMap().moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(-33.8696, 151.2094), 10));
    }

    IconGenerator iconFactory = new IconGenerator(this);
    addIcon(iconFactory, "Default", new LatLng(-33.8696, 151.2094));

    iconFactory.setColor(Color.CYAN);
    addIcon(iconFactory, "Custom color", new LatLng(-33.9360, 151.2070));

    iconFactory.setRotation(90);
    iconFactory.setStyle(IconGenerator.STYLE_RED);
    addIcon(iconFactory, "Rotated 90 degrees", new LatLng(-33.8858, 151.096));

    iconFactory.setContentRotation(-90);
    iconFactory.setStyle(IconGenerator.STYLE_PURPLE);
    addIcon(iconFactory, "Rotate=90, ContentRotate=-90", new LatLng(-33.9992, 151.098));

    iconFactory.setRotation(0);
    iconFactory.setContentRotation(90);
    iconFactory.setStyle(IconGenerator.STYLE_GREEN);
    addIcon(iconFactory, "ContentRotate=90", new LatLng(-33.7677, 151.244));

    iconFactory.setRotation(0);
    iconFactory.setContentRotation(0);
    iconFactory.setStyle(IconGenerator.STYLE_ORANGE);
    addIcon(iconFactory, makeCharSequence(), new LatLng(-33.77720, 151.12412));
}
 
Example #4
Source File: IconGeneratorDemoActivity.java    From android-maps-utils with Apache License 2.0 5 votes vote down vote up
private void addIcon(IconGenerator iconFactory, CharSequence text, LatLng position) {
    MarkerOptions markerOptions = new MarkerOptions().
            icon(BitmapDescriptorFactory.fromBitmap(iconFactory.makeIcon(text))).
            position(position).
            anchor(iconFactory.getAnchorU(), iconFactory.getAnchorV());

    getMap().addMarker(markerOptions);
}
 
Example #5
Source File: DefaultClusterRenderer.java    From android-maps-utils with Apache License 2.0 5 votes vote down vote up
public DefaultClusterRenderer(Context context, GoogleMap map, ClusterManager<T> clusterManager) {
    mMap = map;
    mAnimate = true;
    mDensity = context.getResources().getDisplayMetrics().density;
    mIconGenerator = new IconGenerator(context);
    mIconGenerator.setContentView(makeSquareTextView(context));
    mIconGenerator.setTextAppearance(R.style.amu_ClusterIcon_TextAppearance);
    mIconGenerator.setBackground(makeClusterBackground());
    mClusterManager = clusterManager;
}
 
Example #6
Source File: RealTimeLocationDisplayActivity.java    From NaviBee with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_location_display);

    mapView = findViewById(R.id.displayLocation_mapView);
    mapView.onCreate(savedInstanceState);
    mapView.getMapAsync(this);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        if (checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) !=
                PackageManager.PERMISSION_GRANTED) {
            requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
                    PERMISSIONS_REQUEST_FINE_LOCATION);
        }
    }

    findViewById(R.id.displayLocation_fab).setVisibility(View.GONE);

    updateTimer.scheduleAtFixedRate(updateTask,0, UPDATE_INTERVAL);


    TextView title = findViewById(R.id.chat_locationDisplay_title);
    TextView subtitle = findViewById(R.id.chat_locationDisplay_subtitle);
    ImageView icon = findViewById(R.id.chat_locationDisplay_icon);

    subtitle.setVisibility(View.GONE);


    conv = (PrivateConversation) ConversationManager.getInstance().getConversation(getIntent().getStringExtra(EXTRA_CONVID));
    UserInfoManager.getInstance().getUserInfo(conv.getTargetUid(),(userInfo -> {
        userName = userInfo.getName();
        if (marker!=null) marker.setIcon(BitmapDescriptorFactory.fromBitmap(new IconGenerator(this).makeIcon(userName)));
        title.setText(userName);
        new URLImageViewCacheLoader(userInfo.getPhotoUrl(), icon).roundImage(true).execute();
        update(false);
    }));


    listener = FirebaseFirestore.getInstance()
            .collection("conversations")
            .document(conv.conversationId)
            .collection("realtimeLocations")
            .document(conv.getTargetUid()).addSnapshotListener((snapshots, e) -> {
                if (e != null) {
                    Log.w("RealtimeLocation", "listen:error", e);
                    return;
                }

                if (snapshots.exists()) {
                    Map<String, Object> data = snapshots.getData();
                    location = new LatLng((double) data.get("latitude"), (double) data.get("longitude"));
                    lastUpdate = ((Timestamp)data.get("time")).toDate();
                } else {
                    if (marker != null) {
                        marker.remove();
                        marker = null;
                        location = null;
                    }
                }

    });


}
 
Example #7
Source File: BarometerNetworkActivity.java    From PressureNet with GNU General Public License v3.0 4 votes vote down vote up
private void prepareTemperatureAnimationMarkers(int startFrame) {
	temperatureAnimationStep = startFrame;
	temperatureAnimationMarkerOptions.clear();
	
	IconGenerator iconFactory = new IconGenerator(getApplicationContext());

	iconFactory.setBackground(null);
	// iconFactory.setColor(Color.rgb(230, 230, 230));
	iconFactory.setStyle(R.style.MapTemperatureBackground);
	iconFactory.setTextAppearance(R.style.MapTemperatureText);
			
	if(forecastRecents!=null) {
		if(forecastRecents.size()>0) {
			TemperatureForecast previous = forecastRecents.get(0);
			for (TemperatureForecast forecast : forecastRecents) {
				LatLng position = new LatLng(forecast.getLatitude(), forecast.getLongitude());

				String displayValue = forecast.getDisplayTempValue();
				
				if(previous.getTemperatureValue() < forecast.getTemperatureValue()) {
					displayValue += " ↑";
				} else if(previous.getTemperatureValue() > forecast.getTemperatureValue()) {
					displayValue += " ↓";
				} else {	
					displayValue += "    ";
					
				}
				
		        MarkerOptions markerOptions = new MarkerOptions().
		                icon(BitmapDescriptorFactory.fromBitmap(iconFactory.makeIcon(displayValue))).
		                position(position).
		                anchor(iconFactory.getAnchorU(), iconFactory.getAnchorV());

		        temperatureAnimationMarkerOptions.add(markerOptions);
		        previous = forecast;
			}
			log("added markers to list, count " + temperatureAnimationMarkerOptions.size());
		} else {
			log("forecast recents is size 0, not preparing temperature animation markers");
		}	
	} else {
		log("forecast recents is null, not preparing temperature animation markers");
	}
}