use of com.google.android.gms.maps.model.MarkerOptions in project NPSmiles by bmcglynn1.
the class ItemOneFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.activity_contact_page, container, false);
SupportMapFragment mapFragment = (SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map);
OnMapReadyCallback obj = new OnMapReadyCallback() {
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
LatLng smiles = new LatLng(39.104729, -77.191294);
mMap.addMarker(new MarkerOptions().position(smiles).title("North Potomac Smiles, LLC."));
mMap.moveCamera(CameraUpdateFactory.newLatLng(smiles));
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(smiles, 16));
}
};
mapFragment.getMapAsync(obj);
return view;
}
use of com.google.android.gms.maps.model.MarkerOptions in project iosched by google.
the class MarkerLoadingTask method loadInBackground.
@Override
public List<MarkerEntry> loadInBackground() {
List<MarkerEntry> list = null;
// Create a URI to get a cursor of all map markers
final Uri uri = ScheduleContract.MapMarkers.buildMarkerUri();
Cursor cursor = getContext().getContentResolver().query(uri, MarkerQuery.PROJECTION, null, null, null);
// Create a MarkerModel for each entry
final int count = cursor.getCount();
if (cursor != null) {
list = new ArrayList<>(count);
final IconGenerator labelIconGenerator = MapUtils.getLabelIconGenerator(getContext());
cursor.moveToFirst();
while (!cursor.isAfterLast()) {
// get data
final String id = cursor.getString(MarkerQuery.MARKER_ID);
final int floor = cursor.getInt(MarkerQuery.MARKER_FLOOR);
final float lat = cursor.getFloat(MarkerQuery.MARKER_LATITUDE);
final float lon = cursor.getFloat(MarkerQuery.MARKER_LONGITUDE);
final String typeString = cursor.getString(MarkerQuery.MARKER_TYPE);
final int type = MapUtils.detectMarkerType(typeString);
final String label = cursor.getString(MarkerQuery.MARKER_LABEL);
final LatLng position = new LatLng(lat, lon);
MarkerOptions marker = null;
if (type == MarkerModel.TYPE_LABEL) {
// Label markers contain the label as its icon
marker = MapUtils.createLabelMarker(labelIconGenerator, id, position, label);
} else if (type == MarkerModel.TYPE_ICON) {
// An icon marker is mapped to a drawable based on its full type name
marker = MapUtils.createIconMarker(typeString, id, position, getContext());
} else if (type != MarkerModel.TYPE_INACTIVE) {
// All other markers (that are not inactive) contain a pin icon
marker = MapUtils.createPinMarker(id, position);
}
MarkerModel model = new MarkerModel(id, floor, type, label, null);
MarkerEntry entry = new MarkerEntry(model, marker);
list.add(entry);
cursor.moveToNext();
}
cursor.close();
}
return list;
}
use of com.google.android.gms.maps.model.MarkerOptions in project iosched by google.
the class MapUtils method createVenueMarker.
/**
* Creates a marker for the venue.
*/
public static MarkerOptions createVenueMarker(LatLng position) {
final String title = "VENUE";
final BitmapDescriptor icon = BitmapDescriptorFactory.fromResource(R.drawable.map_marker_venue);
return new MarkerOptions().position(position).title(title).icon(icon).visible(false);
}
use of com.google.android.gms.maps.model.MarkerOptions in project iosched by google.
the class MapUtils method createIconMarker.
/**
* Creates a marker for an icon. The icon is selected in {@link #getDrawableForIconType(Context,
* String)} and anchored at the bottom center for the location.
*/
public static MarkerOptions createIconMarker(final String iconType, final String id, LatLng position, Context context) {
final int iconResource = getDrawableForIconType(context, iconType);
if (iconResource < 1) {
// Not a valid icon type.
return null;
}
final BitmapDescriptor icon = BitmapDescriptorFactory.fromResource(iconResource);
return new MarkerOptions().position(position).title(id).icon(icon).anchor(0.5f, 1f).visible(false);
}
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;
}
Aggregations