use of com.google.android.gms.maps.model.MarkerOptions in project android-maps-utils by googlemaps.
the class Renderer method addKmlPlacemarkToMap.
/**
* Adds a single geometry object to the map with its specified style (used for KML)
*
* @param geometry defines the type of object to add to the map
* @param style defines styling properties to add to the object when added to the map
* @return the object that was added to the map, this is a Marker, Polyline, Polygon or an array
* of either objects
*/
protected Object addKmlPlacemarkToMap(KmlPlacemark placemark, Geometry geometry, KmlStyle style, KmlStyle inlineStyle, boolean isVisible) {
String geometryType = geometry.getGeometryType();
boolean hasDrawOrder = placemark.hasProperty("drawOrder");
float drawOrder = 0;
if (hasDrawOrder) {
try {
drawOrder = Float.parseFloat(placemark.getProperty("drawOrder"));
} catch (NumberFormatException e) {
hasDrawOrder = false;
}
}
switch(geometryType) {
case "Point":
MarkerOptions markerOptions = style.getMarkerOptions();
if (inlineStyle != null) {
setInlinePointStyle(markerOptions, inlineStyle, style.getIconUrl());
} else if (style.getIconUrl() != null) {
// Use shared style
addMarkerIcons(style.getIconUrl(), markerOptions);
}
Marker marker = addPointToMap(markerOptions, (KmlPoint) geometry);
marker.setVisible(isVisible);
setMarkerInfoWindow(style, marker, placemark);
if (hasDrawOrder) {
marker.setZIndex(drawOrder);
}
return marker;
case "LineString":
PolylineOptions polylineOptions = style.getPolylineOptions();
if (inlineStyle != null) {
setInlineLineStringStyle(polylineOptions, inlineStyle);
} else if (style.isLineRandomColorMode()) {
polylineOptions.color(KmlStyle.computeRandomColor(polylineOptions.getColor()));
}
Polyline polyline = addLineStringToMap(polylineOptions, (LineString) geometry);
polyline.setVisible(isVisible);
if (hasDrawOrder) {
polyline.setZIndex(drawOrder);
}
return polyline;
case "Polygon":
PolygonOptions polygonOptions = style.getPolygonOptions();
if (inlineStyle != null) {
setInlinePolygonStyle(polygonOptions, inlineStyle);
} else if (style.isPolyRandomColorMode()) {
polygonOptions.fillColor(KmlStyle.computeRandomColor(polygonOptions.getFillColor()));
}
Polygon polygon = addPolygonToMap(polygonOptions, (DataPolygon) geometry);
polygon.setVisible(isVisible);
if (hasDrawOrder) {
polygon.setZIndex(drawOrder);
}
return polygon;
case "MultiGeometry":
return addMultiGeometryToMap(placemark, (KmlMultiGeometry) geometry, style, inlineStyle, isVisible);
}
return null;
}
use of com.google.android.gms.maps.model.MarkerOptions in project android-maps-utils by googlemaps.
the class KmlStyle method createMarkerOptions.
/**
* Creates a new marker option from given properties of an existing marker option
*
* @param originalMarkerOption An existing MarkerOption instance
* @param iconRandomColorMode True if marker color mode is random, false otherwise
* @param markerColor Color of the marker
* @return A new MarkerOption
*/
private static MarkerOptions createMarkerOptions(MarkerOptions originalMarkerOption, boolean iconRandomColorMode, float markerColor) {
MarkerOptions newMarkerOption = new MarkerOptions();
newMarkerOption.rotation(originalMarkerOption.getRotation());
newMarkerOption.anchor(originalMarkerOption.getAnchorU(), originalMarkerOption.getAnchorV());
if (iconRandomColorMode) {
float hue = getHueValue(computeRandomColor((int) markerColor));
originalMarkerOption.icon(BitmapDescriptorFactory.defaultMarker(hue));
}
newMarkerOption.icon(originalMarkerOption.getIcon());
return newMarkerOption;
}
use of com.google.android.gms.maps.model.MarkerOptions in project actor-platform by actorapp.
the class MapFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
longitude = getArguments().getDouble("longitude");
latitude = getArguments().getDouble("latitude");
final MapView map = new MapView(getActivity());
map.onCreate(null);
map.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(GoogleMap googleMap) {
mapController = googleMap;
googleMap.addMarker(new MarkerOptions().position(new LatLng(latitude, longitude)).title(""));
googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(latitude, longitude), 16));
map.onResume();
}
});
return map;
}
use of com.google.android.gms.maps.model.MarkerOptions in project Signal-Android by WhisperSystems.
the class SignalMapView method display.
public ListenableFuture<Bitmap> display(final SignalPlace place) {
final SettableFuture<Bitmap> future = new SettableFuture<>();
this.mapView.onCreate(null);
this.mapView.onResume();
this.mapView.setVisibility(View.VISIBLE);
this.imageView.setVisibility(View.GONE);
this.mapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(final GoogleMap googleMap) {
googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(place.getLatLong(), 13));
googleMap.addMarker(new MarkerOptions().position(place.getLatLong()));
googleMap.setBuildingsEnabled(true);
googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
googleMap.getUiSettings().setAllGesturesEnabled(false);
googleMap.setOnMapLoadedCallback(new GoogleMap.OnMapLoadedCallback() {
@Override
public void onMapLoaded() {
googleMap.snapshot(new GoogleMap.SnapshotReadyCallback() {
@Override
public void onSnapshotReady(Bitmap bitmap) {
future.set(bitmap);
imageView.setImageBitmap(bitmap);
imageView.setVisibility(View.VISIBLE);
mapView.setVisibility(View.GONE);
mapView.onPause();
mapView.onDestroy();
}
});
}
});
}
});
this.textView.setText(place.getDescription());
return future;
}
use of com.google.android.gms.maps.model.MarkerOptions in project Android-GoogleDirectionAndPlaceLibrary by akexorcist.
the class DirectionActivity1 method onCreate.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_direction_1);
mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(start, 15));
gd = new GoogleDirection(this);
gd.setOnDirectionResponseListener(new OnDirectionResponseListener() {
public void onResponse(String status, Document doc, GoogleDirection gd) {
mDoc = doc;
mMap.addPolyline(gd.getPolyline(doc, 3, Color.RED));
mMap.addMarker(new MarkerOptions().position(start).icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)));
mMap.addMarker(new MarkerOptions().position(end).icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)));
buttonAnimate.setVisibility(View.VISIBLE);
}
});
gd.setOnAnimateListener(new OnAnimateListener() {
public void onStart() {
textProgress.setVisibility(View.VISIBLE);
}
public void onProgress(int progress, int total) {
textProgress.setText(progress + " / " + total);
}
public void onFinish() {
buttonAnimate.setVisibility(View.VISIBLE);
textProgress.setVisibility(View.GONE);
}
});
textProgress = (TextView) findViewById(R.id.textProgress);
textProgress.setVisibility(View.GONE);
buttonRequest = (Button) findViewById(R.id.buttonRequest);
buttonRequest.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
v.setVisibility(View.GONE);
gd.setLogging(true);
gd.request(start, end, GoogleDirection.MODE_DRIVING);
}
});
buttonAnimate = (Button) findViewById(R.id.buttonAnimate);
buttonAnimate.setVisibility(View.GONE);
buttonAnimate.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
v.setVisibility(View.GONE);
gd.animateDirection(mMap, gd.getDirection(mDoc), GoogleDirection.SPEED_FAST, true, false, true, false, null, false, true, null);
}
});
}
Aggregations