本文整理匯總了Java中com.google.android.gms.maps.model.MarkerOptions類的典型用法代碼示例。如果您正苦於以下問題:Java MarkerOptions類的具體用法?Java MarkerOptions怎麽用?Java MarkerOptions使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
MarkerOptions類屬於com.google.android.gms.maps.model包,在下文中一共展示了MarkerOptions類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initMap
import com.google.android.gms.maps.model.MarkerOptions; //導入依賴的package包/類
private void initMap() {
PlaceAutocompleteFragment autocompleteFragment = new PlaceAutocompleteFragment();
CustomMapFragment mapFragment = new CustomMapFragment();
autocompleteFragment.setOnPlaceSelectedListener(this);
mapFragment.setParent(mBinding.scroll);
mapFragment.getMapAsync(this);
FragmentManager manager = getActivity().getFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
transaction.add(R.id.place_autocomplete_fragment, autocompleteFragment);
transaction.add(R.id.google_map_fragment, mapFragment);
transaction.commit();
mMarkerOptions = new MarkerOptions().icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN));
mCircleOptions = new CircleOptions().fillColor(Color.argb(97, 93, 185, 139)).strokeColor(Color.argb(200, 93, 185, 139));
}
示例2: setMarkers
import com.google.android.gms.maps.model.MarkerOptions; //導入依賴的package包/類
private void setMarkers(GoogleMap map, List<Restaurant> restaurants) {
if (map == null) {
return;
}
map.clear();
MarkerOptions options = new MarkerOptions().position(
new LatLng(Prefs.LastLatitude.getDouble(), Prefs.LastLongitude.getDouble()))
.icon(BitmapDescriptorFactory.fromResource(R.drawable.current_location));
map.addMarker(options);
for (Restaurant restaurant : restaurants) {
MarkerOptions markerOptions = new MarkerOptions().position(
new LatLng(restaurant.mLatitude, restaurant.mLongitude))
.title(restaurant.mName)
.icon(BitmapDescriptorFactory.fromResource(R.drawable.restaurant_pin));
Marker marker = map.addMarker(markerOptions);
marker.setTag(restaurant);
}
mMap.setOnInfoWindowClickListener(mInfoWindowClickListener);
}
示例3: showPointerOnMap
import com.google.android.gms.maps.model.MarkerOptions; //導入依賴的package包/類
private void showPointerOnMap(final double latitude, final double longitude) {
mvRestaurantLocation.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(GoogleMap googleMap) {
LatLng latLng = new LatLng(latitude, longitude);
googleMap.addMarker(new MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.marker_flag))
.anchor(0.0f, 1.0f)
.position(latLng));
googleMap.getUiSettings().setMyLocationButtonEnabled(false);
googleMap.getUiSettings().setZoomControlsEnabled(true);
// Updates the location and zoom of the MapView
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(latLng, 15);
googleMap.moveCamera(cameraUpdate);
}
});
}
示例4: onMapReady
import com.google.android.gms.maps.model.MarkerOptions; //導入依賴的package包/類
/**
* Manipulates the map once available.
* This callback is triggered when the map is ready to be used.
* This is where we can add markers or lines, add listeners or move the camera. In this case,
* we just add a marker near Sydney, Australia.
* If Google Play services is not installed on the device, the user will be prompted to install
* it inside the SupportMapFragment. This method will only be triggered once the user has
* installed Google Play services and returned to the app.
*/
@Override
public void onMapReady(GoogleMap googleMap) {
googleMap.clear();
GoToMap = googleMap;
Intent i = getIntent();
ArrayList<LatLng> list1 = i.getParcelableArrayListExtra("key1");
ArrayList<String> list2 = i.getStringArrayListExtra("key2");
ArrayList<String> list3 = i.getStringArrayListExtra("key3");
LatLng latLng = new LatLng(0, 0);
int j = list1.size();
j=j-1;
while (j!=-1)
{
if(list1.get(j)!=latLng)
{ Log.i(list1.get(j).toString(),list1.get(j).toString());
GoToMap.addMarker(new MarkerOptions().position(list1.get(j)).draggable(true).title(list3.get(j).replace(',','.')+" Battery Power "+list2.get(j)));
GoToMap.moveCamera(CameraUpdateFactory.newLatLng(list1.get(j)));
}
j--;
}
// Add a marker in Sydney and move the camera
}
示例5: onMapReady
import com.google.android.gms.maps.model.MarkerOptions; //導入依賴的package包/類
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
// mMap.setOnMapClickListener(this);
Bundle bundle = getIntent().getExtras();
double r_long=bundle.getDouble("lattitude");
double r_lat=bundle.getDouble("longitude");
// Add a marker in Sydney and move the camera
LatLng mark = new LatLng(r_lat, r_long);
CircleOptions circleoptions=new CircleOptions().strokeWidth(2).strokeColor(Color.BLUE).fillColor(Color.parseColor("#500084d3"));
mMap.addMarker(new MarkerOptions().position(mark).title(getAddress(mark)));
mMap.moveCamera(CameraUpdateFactory.newLatLng(mark));
Circle circle=mMap.addCircle(circleoptions.center(mark).radius(5000.0));
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(circleoptions.getCenter(),getZoomLevel(circle)));
}
示例6: onMapReady
import com.google.android.gms.maps.model.MarkerOptions; //導入依賴的package包/類
/**
* Manipulates the map once available.
* This callback is triggered when the map is ready to be used.
* This is where we can add markers or lines, add listeners or move the camera. In this case,
* we just add a marker near Sydney, Australia.
* If Google Play services is not installed on the device, the user will be prompted to install
* it inside the SupportMapFragment. This method will only be triggered once the user has
* installed Google Play services and returned to the app.
*/
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
// Add a marker in Sydney and move the camera
Log.e("zzzz"+MainActivity.mylocationa, ""+MainActivity.myLocationb);
LatLng sydney = new LatLng(MainActivity.lat,MainActivity.longi);
mMap.addMarker(new MarkerOptions().position(sydney).title("Marker at your location"));
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(sydney,16));
Toast.makeText(getApplicationContext(),"At the height of "+MainActivity.diffelevation+" metres",Toast.LENGTH_LONG).show();
}
示例7: addDragListenerMarkerMaker
import com.google.android.gms.maps.model.MarkerOptions; //導入依賴的package包/類
private void addDragListenerMarkerMaker(LineChart speedChart) {
speedChart.setOnChartValueSelectedListener(new OnChartValueSelectedListener() {
@Override
public void onValueSelected(Entry entry, Highlight h) {
Long entryX = (long) entry.getX();
if (timeLocationMap.containsKey(entryX)) {
clearAllMarkersFromMap();
LatLng latLng = timeLocationMap.get(entryX);
mapMarkers.add(googleMap.addMarker(new MarkerOptions().position(latLng)));
}
}
@Override
public void onNothingSelected() {
clearAllMarkersFromMap();
}
});
}
示例8: onLocationChanged
import com.google.android.gms.maps.model.MarkerOptions; //導入依賴的package包/類
@Override
public void onLocationChanged(Location location) {
currentLatitude = location.getLatitude();
currentLongitude = location.getLongitude();
//Toast.makeText(this, currentLatitude + " WORKS " + currentLongitude + "", Toast.LENGTH_LONG).show();
LatLng latLng = new LatLng(currentLatitude, currentLongitude);
googleMap.addMarker(new MarkerOptions().position(latLng));
googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 15));
googleMap.animateCamera(CameraUpdateFactory.zoomIn());
googleMap.animateCamera(CameraUpdateFactory.zoomTo(15), 2000, null);
getNearByClinics(currentLongitude, currentLatitude);
}
示例9: 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);
}
示例10: onBeforeClusterRendered
import com.google.android.gms.maps.model.MarkerOptions; //導入依賴的package包/類
@Override
protected void onBeforeClusterRendered(Cluster<IssueMarker> cluster, MarkerOptions options) {
super.onBeforeClusterRendered(cluster, options);
// Cluster customization
Context context = mMap.getContext();
int clusterSize = cluster.getSize();
String clusterIconRes = "cluster1";
for (int i = 0; i < CLUSTER_THRESHOLDS.length; i++) {
int threshold = CLUSTER_THRESHOLDS[i];
if (clusterSize >= threshold) clusterIconRes = "cluster" + (i + 2);
}
mClusterIconGenerator.setBackground(getClusterIcon(context, clusterIconRes));
mClusterIconGenerator.setTextAppearance(R.style.ClusterIconText);
Bitmap sizeIcon = mClusterIconGenerator.makeIcon(String.valueOf(clusterSize));
options.icon(BitmapDescriptorFactory.fromBitmap(sizeIcon));
}
示例11: 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);
}
}
示例12: onLocationChanged
import com.google.android.gms.maps.model.MarkerOptions; //導入依賴的package包/類
@Override
public void onLocationChanged(Location location) {
mLastLocation = location;
//remove previous current location Marker
if (marker != null) {
marker.remove();
}
current_Latitude = mLastLocation.getLatitude();
current_Longitude = mLastLocation.getLongitude();
marker = mMap.addMarker(new MarkerOptions().position(new LatLng(current_Latitude, current_Longitude))
.title("My Location").icon(BitmapDescriptorFactory
.defaultMarker(BitmapDescriptorFactory.HUE_RED)));
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(current_Latitude, current_Longitude), 8));
}
示例13: onActivityResult
import com.google.android.gms.maps.model.MarkerOptions; //導入依賴的package包/類
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == PLACE_AUTOCOMPLETE_REQUEST_CODE) {
if (resultCode == RESULT_OK) {
// Move camera to that place and add normal marker
Place place = PlaceAutocomplete.getPlace(this, data);
this.googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(place.getLatLng(), 17), 1000, null);
this.googleMap.addMarker(new MarkerOptions().position(place.getLatLng()));
// Set text on "edit text"
binding.placeSearch.setText(place.getName());
} else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
Status status = PlaceAutocomplete.getStatus(this, data);
Log.w(TAG, status.getStatusMessage());
} else if (resultCode == RESULT_CANCELED) {
// The user canceled the operation -- clear text
binding.placeSearch.setText("");
}
}
}
示例14: onMapReady
import com.google.android.gms.maps.model.MarkerOptions; //導入依賴的package包/類
/**
* Manipulates the map once available.
* This callback is triggered when the map is ready to be used.
* This is where we can add markers or lines, add listeners or move the camera. In this case,
* we just add a marker near Sydney, Australia.
* If Google Play services is not installed on the device, the user will be prompted to install
* it inside the SupportMapFragment. This method will only be triggered once the user has
* installed Google Play services and returned to the app.
*/
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
storePlace(getIntent().getExtras().getString("place"));
flocationx=getIntent().getDoubleArrayExtra("locationx");
flocationy=getIntent().getDoubleArrayExtra("locationy");
fname=getIntent().getStringArrayListExtra("name");
mylat=getIntent().getExtras().getDouble("mylat");
mylog=getIntent().getExtras().getDouble("mylog");
LatLng place = new LatLng(locationx , locationy);
mMap.addMarker(new MarkerOptions().position(place).title(name).icon(BitmapDescriptorFactory.fromBitmap(BitmapFactory.decodeResource(getResources(),R.mipmap.marker))));
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(place,14));
for(int i=0;i<fname.size();i++) {
mMap.addMarker(new MarkerOptions().position(new LatLng(flocationy[i], flocationx[i])).title(fname.get(i)));
}
mMap.addMarker(new MarkerOptions().position(new LatLng(mylat, mylog)).title("ME"));
}
示例15: onMapReady
import com.google.android.gms.maps.model.MarkerOptions; //導入依賴的package包/類
@Override
public void onMapReady(GoogleMap googleMap) {
gMap =googleMap;
// Add a marker in Sydney and move the camera
LatLng sucre = new LatLng(-19.040179078634807, -65.25621296313443);
MarkerOptions marker = new MarkerOptions()
.position(sucre)
.title("Bienvenidos a la CCBOL2017")
.draggable(true);
gMap.addMarker(marker);
CameraPosition camera = new CameraPosition.Builder()
.target(sucre)
.zoom(18) //limite ->21
.bearing(0) // 0 - 365
.tilt(45) // limite ->90
.build();
gMap.animateCamera(CameraUpdateFactory.newCameraPosition(camera));
}