当前位置: 首页>>代码示例>>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;未经允许,请勿转载。