本文整理汇总了Java中com.google.android.gms.maps.model.MarkerOptions.position方法的典型用法代码示例。如果您正苦于以下问题:Java MarkerOptions.position方法的具体用法?Java MarkerOptions.position怎么用?Java MarkerOptions.position使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.maps.model.MarkerOptions
的用法示例。
在下文中一共展示了MarkerOptions.position方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addGateway
import com.google.android.gms.maps.model.MarkerOptions; //导入方法依赖的package包/类
public void addGateway(Packet packet) {
for (Gateway gateway : packet.getGateways()) {
double gwLat = gateway.getLatitude();
double gwLon = gateway.getLongitude();
if (gwLat != 0 && gwLon != 0) {
String gatewayId = gateway.getGatewayID();
if (gatewaysWithMarkers.contains(gatewayId)) {
//already has a marker for this gateway
} else {
MarkerOptions gwoptions = new MarkerOptions();
gwoptions.icon(BitmapDescriptorFactory.fromResource(R.drawable.gateway_dot));
gwoptions.position(new LatLng(gwLat, gwLon));
gwoptions.title(gatewayId);
//gwoptions.snippet(gatewayId);
gwoptions.anchor((float) 0.5, (float) 0.5);
mMap.addMarker(gwoptions);
gatewaysWithMarkers.add(gatewayId);
}
}
}
}
示例2: drawNext
import com.google.android.gms.maps.model.MarkerOptions; //导入方法依赖的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);
}
示例3: ShowNearbyPlaces
import com.google.android.gms.maps.model.MarkerOptions; //导入方法依赖的package包/类
private void ShowNearbyPlaces(List<HashMap<String, String>> nearbyPlacesList) {
for (int i = 0; i < nearbyPlacesList.size(); i++) {
Log.d("onPostExecute","Entered into showing locations");
MarkerOptions markerOptions = new MarkerOptions();
HashMap<String, String> googlePlace = nearbyPlacesList.get(i);
double lat = Double.parseDouble(googlePlace.get("lat"));
double lng = Double.parseDouble(googlePlace.get("lng"));
String placeName = googlePlace.get("place_name");
String vicinity = googlePlace.get("vicinity");
LatLng latLng = new LatLng(lat, lng);
markerOptions.position(latLng);
markerOptions.title(placeName + " : " + vicinity);
mMap.addMarker(markerOptions);
markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED));
//move map camera
mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
mMap.animateCamera(CameraUpdateFactory.zoomTo(11));
}
}
示例4: onPostExecute
import com.google.android.gms.maps.model.MarkerOptions; //导入方法依赖的package包/类
@Override
protected void onPostExecute(List<HashMap<String, String>> list) {
googleMap.clear();
for (int i = 0; i < list.size(); i++) {
MarkerOptions markerOptions = new MarkerOptions();
HashMap<String, String> googlePlace = list.get(i);
double lat = Double.parseDouble(googlePlace.get("lat"));
double lng = Double.parseDouble(googlePlace.get("lng"));
String placeName = googlePlace.get("place_name");
//String vicinity = googlePlace.get("vicinity");
LatLng latLng = new LatLng(lat, lng);
markerOptions.position(latLng);
markerOptions.title(placeName);
markerOptions.icon(BitmapDescriptorFactory.fromResource(R.drawable.custom_marker));
googleMap.addMarker(markerOptions);
}
}
示例5: PlacePinAndPositionCamera
import com.google.android.gms.maps.model.MarkerOptions; //导入方法依赖的package包/类
public void PlacePinAndPositionCamera(LatLng addressPosition) {
MarkerOptions markerOptions = new MarkerOptions();
markerOptions.position(addressPosition);
mMap.addMarker(markerOptions
.title("Crisis Location").icon(BitmapDescriptorFactory
.defaultMarker(BitmapDescriptorFactory.HUE_RED)));
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(addressPosition, 12));
LatLngBounds.Builder builder = new LatLngBounds.Builder();
builder.include(addressPosition);
LatLngBounds bounds = builder.build();
int padding = 150; // offset from edges of the map in pixels
CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, padding);
mMap.animateCamera(cu);
}
示例6: onLocationChanged
import com.google.android.gms.maps.model.MarkerOptions; //导入方法依赖的package包/类
@Override
public void onLocationChanged(Location location) {
//place marker at current position
//mGoogleMap.clear();
if (currLocationMarker != null) {
currLocationMarker.remove();
}
latLng = new LatLng(location.getLatitude(), location.getLongitude());
MarkerOptions markerOptions = new MarkerOptions();
markerOptions.position(latLng);
markerOptions.title(getString(R.string.current_position));
markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_MAGENTA));
currLocationMarker = mGoogleMap.addMarker(markerOptions);
//zoom to current position:
CameraPosition cameraPosition = new CameraPosition.Builder()
.target(latLng).zoom(14).build();
mGoogleMap.animateCamera(CameraUpdateFactory
.newCameraPosition(cameraPosition));
mMocketClient.pushLatLngToServer(latLng);
}
示例7: onMapReady
import com.google.android.gms.maps.model.MarkerOptions; //导入方法依赖的package包/类
@Override
public void onMapReady(GoogleMap googleMap) {
//Inicializo el mapa
MapsInitializer.initialize(getContext());
mMap = googleMap;
//Si tengo proyectos los muestro en el mapa
if (proyecto.getCoordenadas().compareTo("") != 0) {
String[] coordenadas = proyecto.getCoordenadas().split(",");
double lat = Double.parseDouble(coordenadas[0]);
double lon = Double.parseDouble(coordenadas[1]);
posicionProyecto = new LatLng(lat, lon);
MarkerOptions markerOptions = new MarkerOptions();
markerOptions.title(proyecto.getNombre());
//Pongo la descripción en el infowindow solo con 10 caracteres
if (proyecto.getDescripcion().length() > 50)
markerOptions.snippet(proyecto.getDescripcion().substring(0, 50));
else
markerOptions.snippet(proyecto.getDescripcion());
markerOptions.position(posicionProyecto);
mMap.addMarker(markerOptions);
}
// Movemos la camara a la posicion del usuario
if (miPosicion != null)
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(miPosicion, 3));
}
示例8: onToggleAction
import com.google.android.gms.maps.model.MarkerOptions; //导入方法依赖的package包/类
@Override
protected void onToggleAction() {
if (shouldShow()) {
for (final LatLng latLng : this.boatSpawns) {
final MarkerOptions markerOptions = createMarkerOptions();
markerOptions.position(latLng);
this.boatMarkers.add(this.mapController.addMarker(markerOptions));
}
} else {
for (final Marker marker : this.boatMarkers) {
marker.remove();
}
this.boatMarkers.clear();
}
}
示例9: addMarker
import com.google.android.gms.maps.model.MarkerOptions; //导入方法依赖的package包/类
/**
* Helper function.
*
* @param latLng position on {@link GoogleMap} to create a marker.
* @return marker on map.
*/
@NonNull
private Marker addMarker(@NonNull final LatLng latLng) {
final MarkerOptions options = createMarkerOptions();
options.position(latLng);
return this.mapController.addMarker(options);
}
示例10: addMeasurementMarker
import com.google.android.gms.maps.model.MarkerOptions; //导入方法依赖的package包/类
public void addMeasurementMarker(Packet packet) {
createMarkerBitmaps(); //create markers if they do not exist
MarkerOptions options = new MarkerOptions();
double rssi = packet.getMaxRssi();
if (rssi == 0) {
options.icon(circleBlack);
} else if (rssi < -120) {
options.icon(circleBlue);
} else if (rssi < -115) {
options.icon(circleCyan);
} else if (rssi < -110) {
options.icon(circleGreen);
} else if (rssi < -105) {
options.icon(circleYellow);
} else if (rssi < -100) {
options.icon(circleOrange);
} else {
options.icon(circleRed);
}
options.position(new LatLng(packet.getLatitude(), packet.getLongitude()));
options.anchor((float) 0.5, (float) 0.5);
options.title("RSSI: " + packet.getMaxRssi() + "dBm\n" +
"SNR: " + packet.getMaxSnr() + "dB\n" +
"Gateways: " + packet.gateways.size());
mMap.addMarker(options);
markersOnMap.add(options); //save a list of markers used for auto zooming
}
示例11: replaceMarker
import com.google.android.gms.maps.model.MarkerOptions; //导入方法依赖的package包/类
/**
* Adds a marker to the current position.
*/
private void replaceMarker(LatLng latLng) {
// Remove the previous marker
if (currentLocationMarker != null) {
currentLocationMarker.remove();
}
MarkerOptions markerOptions = new MarkerOptions();
markerOptions.position(latLng);
// Add a marker indicating the user's current position to the Google Map
currentLocationMarker = googleMap.addMarker(markerOptions);
}
示例12: onLocationChanged
import com.google.android.gms.maps.model.MarkerOptions; //导入方法依赖的package包/类
@Override
public void onLocationChanged(Location location) {
Log.d("onLocationChanged", "entered");
mLastLocation = location;
if (mCurrLocationMarker != null) {
mCurrLocationMarker.remove();
}
//Place current location marker
latitude = location.getLatitude();
longitude = location.getLongitude();
LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
MarkerOptions markerOptions = new MarkerOptions();
markerOptions.position(latLng);
markerOptions.title("Current Position");
markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_MAGENTA));
mCurrLocationMarker = mMap.addMarker(markerOptions);
//move map camera
mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
mMap.animateCamera(CameraUpdateFactory.zoomTo(18));
Log.d("onLocationChanged", String.format("latitude:%.3f longitude:%.3f",latitude,longitude));
//stop location updates
if (mGoogleApiClient != null) {
LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this);
Log.d("onLocationChanged", "Removing Location Updates");
}
Log.d("onLocationChanged", "Exit");
}
示例13: onLocationChanged
import com.google.android.gms.maps.model.MarkerOptions; //导入方法依赖的package包/类
@Override
public void onLocationChanged(Location location) {
Log.d("onLocationChanged", "entered");
mLastLocation = location;
if (mCurrLocationMarker != null) {
mCurrLocationMarker.remove();
}
//Place current location marker
latitude = location.getLatitude();
longitude = location.getLongitude();
LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
MarkerOptions markerOptions = new MarkerOptions();
markerOptions.position(latLng);
markerOptions.title("Current Position");
markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_MAGENTA));
mCurrLocationMarker = mMap.addMarker(markerOptions);
//move map camera
mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
mMap.animateCamera(CameraUpdateFactory.zoomTo(11));
Toast.makeText(MapsActivity2.this,"Your Current Location", Toast.LENGTH_LONG).show();
Log.d("onLocationChanged", String.format("latitude:%.3f longitude:%.3f",latitude,longitude));
//stop location updates
if (mGoogleApiClient != null) {
LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this);
Log.d("onLocationChanged", "Removing Location Updates");
}
Log.d("onLocationChanged", "Exit");
}
示例14: onLocationChanged
import com.google.android.gms.maps.model.MarkerOptions; //导入方法依赖的package包/类
@Override
public void onLocationChanged(Location location) {
Log.d("onLocationChanged", "entered");
mLastLocation = location;
if (mCurrLocationMarker != null) {
mCurrLocationMarker.remove();
}
//Place current location marker
latitude = location.getLatitude();
longitude = location.getLongitude();
LatLng latLng = new LatLng(latitude1, longitude1);
MarkerOptions markerOptions = new MarkerOptions();
markerOptions.position(latLng);
markerOptions.title("Current Position");
markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_MAGENTA));
mCurrLocationMarker = mMap.addMarker(markerOptions);
//move map camera
mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
mMap.animateCamera(CameraUpdateFactory.zoomTo(11));
Toast.makeText(MapsActivity3.this,"Your Current Location", Toast.LENGTH_LONG).show();
Log.d("onLocationChanged", String.format("latitude:%.3f longitude:%.3f",latitude,longitude));
//stop location updates
if (mGoogleApiClient != null) {
LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this);
Log.d("onLocationChanged", "Removing Location Updates");
}
Log.d("onLocationChanged", "Exit");
}
示例15: addMarker
import com.google.android.gms.maps.model.MarkerOptions; //导入方法依赖的package包/类
/**
* Adds a marker to the map
*
* @param marker marker to be added
*
* @return true if marker has been successfully added, false otherwise
*/
public Marker addMarker(com.ubudu.gmaps.model.Marker marker){
if(marker.getLocation()==null)
return null;
if(marker.getTitle()==null)
marker.setTitle("");
MarkerOptions markerOptions = marker.getMarkerOptionsStrategy().getNormalMarkerOptions();
markerOptions.position(marker.getLocation());
markerOptions.title(marker.getTitle());
Marker customMarker = addMarkerToGoogleMap(markerOptions);
if(customMarker!=null)
customMarkersMap.put(marker,customMarker);
return customMarker;
}