本文整理汇总了Java中com.google.android.gms.maps.model.Marker类的典型用法代码示例。如果您正苦于以下问题:Java Marker类的具体用法?Java Marker怎么用?Java Marker使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Marker类属于com.google.android.gms.maps.model包,在下文中一共展示了Marker类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showMarkers
import com.google.android.gms.maps.model.Marker; //导入依赖的package包/类
private void showMarkers() {
googleMap.clear();
Observable
.fromIterable(currentDevices)
.subscribe(device -> {
Location center = GeoHash.fromString(device.getGeoHash()).getCenter();
Marker marker = googleMap.addMarker(new MarkerOptions()
.position(new LatLng(center.getLatitude(), center.getLongitude()))
.icon(BitmapDescriptorFactory.fromResource(R.mipmap.ic_launcher))
.flat(true)
.title(device.getName())
.snippet(device.getAddress())
);
Bitmap bitmap = Device.getBitmapImage(device.getImage(), getResources());
Bitmap bmp = Bitmap.createScaledBitmap(bitmap, markerSize, markerSize, false);
bitmap.recycle();
marker.setIcon(BitmapDescriptorFactory.fromBitmap(bmp));
});
}
示例2: getInfoContents
import com.google.android.gms.maps.model.Marker; //导入依赖的package包/类
@Override
public View getInfoContents(Marker marker) {
Gson gson = new Gson();
Station station = gson.fromJson(marker.getTitle(), Station.class);
titleTextView = (TextView) customView.findViewById(R.id.nameTextView);
addressTextView = (TextView) customView.findViewById(R.id.streetTextView);
totalTextView = (TextView) customView.findViewById(R.id.totalTextView);
freeTextView = (TextView) customView.findViewById(R.id.freeTextView);
engagedTextView = (TextView) customView.findViewById(R.id.engagedTextView);
if (station != null) {
titleTextView.setText(station.getNumberStation() + " " + station.getNombre());
addressTextView.setText(station.getAddress());
totalTextView.setText(activity.getString(R.string.bases) + "\n" + Integer.parseInt(station.getNumberBases()));
freeTextView.setText(activity.getString(R.string.bases_free) + "\n" + Integer.parseInt(station.getBasesFree()));
engagedTextView.setText(activity.getString(R.string.bases_engaged) + "\n" + Integer.parseInt(station.getBikeEngaged()));
return customView;
} else {
return null;
}
}
示例3: testIssueMarkerAdded
import com.google.android.gms.maps.model.Marker; //导入依赖的package包/类
@Test
public void testIssueMarkerAdded() throws MapNotLoadedException {
Issue issueMock = getIssueMock();
Marker markerMock = getMarkerMock();
assertThat(mMap.isMapLoaded(), is(false));
assertThat(mMap.getMarkers(), is(nullValue()));
try {
mMap.addIssueMarker(issueMock);
fail("Trying to addItem issue when map is not present!");
} catch (MapNotLoadedException ignore) {}
mMap.onMapReady(mGoogleMap);
when(mMap.isMapReady()).thenReturn(true);
mMap.addIssueMarker(issueMock);
assertThat(mMap.isMapLoaded(), is(true));
assertThat(mMap.getMarkers(), is(not(nullValue())));
IssueMarker marker = mMap.getMarkers().get(ISSUE_MOCK_ID.toUpperCase());
marker.render(markerMock, mock(ClusterManager.class));
assertThat(marker, is(instanceOf(IssueMarker.class)));
assertThat(marker.getIssue(), is(sameInstance(issueMock)));
assertThat(marker.getPosition(), is(markerMock.getPosition()));
assertThat(marker.isRendered(), is(true));
assertThat(markerMock.isVisible(), is(true));
}
示例4: settaMarkersGiaPresenti
import com.google.android.gms.maps.model.Marker; //导入依赖的package包/类
/**
* Imposta un marker per ogni parcheggio già presente in zona
*/
void settaMarkersGiaPresenti() {
// rimuovi tutti i markers
for(Marker m : mMarkerListPresenti)
m.remove();
mMarkerListPresenti.clear();
// aggiungi un marker per ogni posizione
for (Parcheggio p : ElencoParcheggi.getInstance().getListParcheggi()) {
LatLng coordParcheggio = p.getCoordinate();
Marker marker = mMappa.addMarker(new MarkerOptions()
.position(coordParcheggio)
.title(p.getIndirizzo())
.icon(BitmapDescriptorFactory.defaultMarker(138)));
// Associo al marker un tag che corrisponde al parcheggio in questo modo posso
// poi eliminarlo direttamente
marker.setTag(p);
mMarkerListPresenti.add(marker);
}
mMainActivity.modificaTxtMarkerPresenti(ElencoParcheggi.getInstance().getListParcheggi().size());
}
示例5: removeSpawnPoint
import com.google.android.gms.maps.model.Marker; //导入依赖的package包/类
public static void removeSpawnPoint(final Context context, final Marker marker) {
//Put up the Yes/No message box
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder
.setTitle("Remove Pokemon spawn marker?")
.setMessage("Are you sure?")
.setIcon(android.R.drawable.ic_dialog_alert)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
//Yes button clicked, do something
marker.remove();
mSpawnPoints.remove(marker);
removeSpawnPointFromDb(context, marker);
}
})
.setNegativeButton("No", null) //Do nothing on no
.show();
}
示例6: getInfoContents
import com.google.android.gms.maps.model.Marker; //导入依赖的package包/类
/**
* Método de Pop-up de cada marker
* @param marker
* @return markerView
*/
@Override
public View getInfoContents(Marker marker) {
TextView tvLocality = (TextView) this.markerView.findViewById(R.id.tv_locality);
TextView tvLat = (TextView) this.markerView.findViewById(R.id.tv_lat);
TextView tvLng = (TextView) this.markerView.findViewById(R.id.tv_lng);
TextView tvSnippet = (TextView) this.markerView.findViewById(R.id.tv_snippet);
LatLng location = marker.getPosition();
tvLocality.setText(marker.getTitle());
tvLat.setText("Latitude: " + location.latitude);
tvLng.setText("Longitude: " + location.longitude);
tvSnippet.setText(marker.getTitle());
return this.markerView;
}
示例7: onMarkerClick
import com.google.android.gms.maps.model.Marker; //导入依赖的package包/类
@Override
public boolean onMarkerClick(Marker marker) {
Object markerTag = marker.getTag();
if (markerTag instanceof Cluster) {
//noinspection unchecked
Cluster<T> cluster = (Cluster<T>) marker.getTag();
//noinspection ConstantConditions
List<T> clusterItems = cluster.getItems();
if (mCallbacks != null) {
if (clusterItems.size() > 1) {
return mCallbacks.onClusterClick(cluster);
} else {
return mCallbacks.onClusterItemClick(clusterItems.get(0));
}
}
}
return false;
}
示例8: drawNext
import com.google.android.gms.maps.model.Marker; //导入依赖的package包/类
public Marker drawNext() {
MarkerOptions options = new MarkerOptions();
if (isFirstPop) {
options.position(path.getFirst().getStart());
options.icon(firstNodeIcon);
isFirstPop = false;
} else {
last = path.pop();
options.position(last.getEnd());
if (path.size() == 0) {
options.icon(lastNodeIcon);
} else {
options.icon(middleNodeIcon);
}
}
return map.addMarker(options);
}
示例9: onInfoWindowClick
import com.google.android.gms.maps.model.Marker; //导入依赖的package包/类
@Override
public void onInfoWindowClick(final Marker marker) {
final Memory memory = mMemories.get(marker.getId());
String[] actions = {"Delete"};
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(memory.city+", "+memory.country)
.setItems(actions, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (which == 0){
marker.remove();
mDataSource.deleteMemory(memory);
}
}
});
builder.create().show();
}
示例10: getInfoContents
import com.google.android.gms.maps.model.Marker; //导入依赖的package包/类
@Override
public View getInfoContents(Marker marker)
{
if (balloon == null)
return null;
if (balloonMarker == null || ! balloonMarker.equals(marker))
return null;
// final FrameLayout view = new FrameLayout(getActivity());
final RMBTBalloonOverlayView bv = new RMBTBalloonOverlayView(getActivity());
final View view = bv.setupView(getActivity(), null);
bv.setBalloonData(balloon, null);
// view.addView(bv);
return view;
}
示例11: removeMarker
import com.google.android.gms.maps.model.Marker; //导入依赖的package包/类
/**
* Removes the given marker from the map layout
*
* @param marker marker to remove
* @return true if marker has been removed, false if it has not been found
*/
public boolean removeMarker(Marker marker) {
synchronized (customMarkersMap) {
if (customMarkersMap.containsValue(marker)){
Iterator<com.ubudu.gmaps.model.Marker> iterator = customMarkersMap.keySet().iterator();
while(iterator.hasNext()) {
com.ubudu.gmaps.model.Marker m = iterator.next();
Marker googleMarker = customMarkersMap.get(m);
if(googleMarker.equals(marker)) {
googleMarker.remove();
iterator.remove();
return true;
}
}
}
}
return false;
}
示例12: getMarkersWithTags
import com.google.android.gms.maps.model.Marker; //导入依赖的package包/类
/**
*
* @param tags tags to look for
* @return markers matching the given tag
*/
private Map<com.ubudu.gmaps.model.Marker, Marker> getMarkersWithTags(List<String> tags){
Map<com.ubudu.gmaps.model.Marker, Marker> result = new HashMap<>();
synchronized (customMarkersMap) {
for (com.ubudu.gmaps.model.Marker marker : customMarkersMap.keySet()) {
boolean markerMatchesTags = true;
for (String tag : tags) {
if (!marker.getTags().contains(tag)) {
markerMatchesTags = false;
break;
}
}
if (markerMatchesTags)
result.put(marker, customMarkersMap.get(marker));
}
}
return result;
}
示例13: setFloorElementsVisible
import com.google.android.gms.maps.model.Marker; //导入依赖的package包/类
/**
* Change the visibility of all Markers and TileOverlays for a floor.
*/
private void setFloorElementsVisible(int floor, boolean visible) {
// Overlays
final TileOverlay overlay = mTileOverlays.get(floor);
if (overlay != null) {
overlay.setVisible(visible);
}
// Markers
final ArrayList<Marker> markers = mMarkersFloor.get(floor);
if (markers != null) {
for (Marker m : markers) {
m.setVisible(visible);
}
}
}
示例14: setMarker
import com.google.android.gms.maps.model.Marker; //导入依赖的package包/类
private Marker setMarker(User userData, LatLng currentUserLocation) {
Marker marker;
if (userData.getMapPhoto() != null) { // Set photo as icon if it's present
Bitmap bitmap = PhotoFixer.makeCircle(userData.getMapPhoto());
marker = googleMap.addMarker(new MarkerOptions()
.position(currentUserLocation)
.anchor(0.5f, 0.5f)
.icon(BitmapDescriptorFactory.fromBitmap(bitmap)));
} else { // Set default photo if it's not present
marker = googleMap.addMarker(new MarkerOptions().position(currentUserLocation)
.anchor(0.5f, 0.5f)
.icon(BitmapDescriptorFactory.fromBitmap(Bitmap.createScaledBitmap(
BitmapFactory.decodeResource(getContext().getResources(),
R.mipmap.anonymous_user), 100, 100, false))));
}
return marker;
}
示例15: onMapReady
import com.google.android.gms.maps.model.Marker; //导入依赖的package包/类
@Override
public void onMapReady(GoogleMap googleMap) {
GoogleMapsModel.setMap(googleMap);
/*Verificação de tipos de mapa*/
if (Constants.MAP_TYPE_HYBRID == SharedPreferencesUtil.getTypeMaps(this)) {
GoogleMapsModel.getMap().setMapType(Constants.MAP_TYPE_HYBRID);
} else {
GoogleMapsModel.getMap().setMapType(Constants.MAP_TYPE_NORMAL);
}
invokeAddMarkerMapOther.onAddMarkerFirebase(); //adicionando os marcados diretamente do firebase
GoogleMapsModel.getMap().moveCamera(CameraUpdateFactory.newLatLngZoom(Constants.CENTER_LOCATION, 16)); /*Centro do mapa*/
/*Botões de Zoom*/
GoogleMapsModel.getMap().getUiSettings().setZoomControlsEnabled(true);
infoWindow();
/*Listener de cada marker*/
GoogleMapsModel.getMap().setOnInfoWindowClickListener(new GoogleMap.OnInfoWindowClickListener() {
@Override
public void onInfoWindowClick(Marker marker) {
DataBaseUtil dataBaseUtil = new DataBaseUtil(context); /*Instância da base de dados local*/
String name = marker.getTitle();
LocationModel locationModel = dataBaseUtil.getLocation(name);
if (name.equals(locationModel.getName())) {
AlertDialogMessage alertDialogMessage = new AlertDialogMessage();
alertDialogMessage.alertDialogMarker(context, locationModel.getId(),
locationModel.getName(), locationModel.getAddress(),
locationModel.getDescription(), locationModel.getLatitude(), locationModel.getLongitude());
}
}
});
}