當前位置: 首頁>>代碼示例>>Java>>正文


Java MarkerOptions類代碼示例

本文整理匯總了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));

    }
 
開發者ID:OldBigBuddha,項目名稱:AlarmWithL-T,代碼行數:19,代碼來源:SettingFragment.java

示例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);
}
 
開發者ID:boldijar,項目名稱:today-menu-android,代碼行數:20,代碼來源:RestaurantsMapFragment.java

示例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);
        }
    });
}
 
開發者ID:pranayairan,項目名稱:YelpQL,代碼行數:19,代碼來源:BusinessDetailsActivity.java

示例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
}
 
開發者ID:ayushghd,項目名稱:iSPY,代碼行數:33,代碼來源:MapsActivity.java

示例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)));
    }
 
開發者ID:jamesgeorge007,項目名稱:TrackIn-Android-Application,代碼行數:17,代碼來源:cordmap.java

示例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();
         }
 
開發者ID:iamjaspreetsingh,項目名稱:LifeSaver,代碼行數:22,代碼來源:MapsActivity.java

示例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();
        }
    });
}
 
開發者ID:ponewheel,項目名稱:android-ponewheel,代碼行數:19,代碼來源:RideDetailActivity.java

示例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);

}
 
開發者ID:webianks,項目名稱:Crimson,代碼行數:18,代碼來源:SearchClinics.java

示例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);
    }
 
開發者ID:panzerama,項目名稱:Dispatch,代碼行數:20,代碼來源:MainActivity.java

示例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));
}
 
開發者ID:ArnauBlanch,項目名稱:civify-app,代碼行數:17,代碼來源:IssueMarkerClusterRenderer.java

示例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);
        }
    }
 
開發者ID:webianks,項目名稱:Crimson,代碼行數:19,代碼來源:PlacesDisplayTask.java

示例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));

}
 
開發者ID:CMPUT301W17T08,項目名稱:Moodr,代碼行數:18,代碼來源:MapsActivity.java

示例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("");
		}
	}
}
 
開發者ID:EduardoVernier,項目名稱:bikedeboa-android,代碼行數:21,代碼來源:MapActivity.java

示例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"));
}
 
開發者ID:ChristopherJdL,項目名稱:wheretomeet-android,代碼行數:31,代碼來源:MapsActivity.java

示例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));
}
 
開發者ID:gnujavasergio,項目名稱:android-googlemaps,代碼行數:23,代碼來源:MapFragment.java


注:本文中的com.google.android.gms.maps.model.MarkerOptions類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。