/** * 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 LatLng minicurso3 = new LatLng(2.834377, -60.695445); LatLng minicurso5 = new LatLng(2.835402, -60.694514); LatLng ufrr = new LatLng(2.833946, -60.693431); LatLng palestra = new LatLng(2.833998, -60.691348); mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(ufrr, 16)); String text[] = {getString(R.string.pin_minicurso), getString(R.string.pin_palestra)}; mMap.addMarker( new MarkerOptions() .icon(BitmapDescriptorFactory.fromResource(R.mipmap.ic_pin_azul_azul)) .position(minicurso3) .title(text[0])); mMap.addMarker( new MarkerOptions() .icon(BitmapDescriptorFactory.fromResource(R.mipmap.ic_pin_azul_azul)) .position(minicurso5) .title(text[0])); mMap.addMarker( new MarkerOptions() .icon(BitmapDescriptorFactory.fromResource(R.mipmap.ic_pin_verd_azul)) .position(palestra) .title(text[1])); mMap.setMyLocationEnabled(true); barra.setVisibility(View.GONE); }
private void addMarkedMarkers() { // add marked markers // add markets markedList = MarkedContent.ITEMS_DISTINCT(); for (MarkedItem item : markedList) { // is the marked add more than once int numberOfMarkets = MarkedContent.numberOfMarkets(item.name); BitmapDescriptor icon = BitmapDescriptorFactory.fromResource(R.drawable.da_marker_red); if (numberOfMarkets <= 1) { icon = BitmapDescriptorFactory.fromResource(R.drawable.da_marker_yellow); } MarkerOptions markerOption = new MarkerOptions() .position(new LatLng(item.latitude, item.longitude)) .title(item.name) .snippet("klik for at se detaljer") .anchor(0.5f, 0.5f) .icon(icon); Marker marker = googleMap.addMarker(markerOption); item.markerId = marker.getId(); } }
private static BitmapDescriptor getIcon(Gcp gcp) { if (gcp.isMarked) { return BitmapDescriptorFactory.fromResource(R.drawable.placemark_circle_red); } else { return BitmapDescriptorFactory.fromResource(R.drawable.placemark_circle_blue); } }
@Override public void onMapReady(GoogleMap googleMap) { mGoogleMap = googleMap; mGoogleMap.setMyLocationEnabled(true); if (mLocation != null) { animateToLocation(mLocation); } if (markerDataMap == null) { markerDataMap = new HashMap<>(); LatLng report = new LatLng(12.9602028, 77.6430893); Marker reportMarker = googleMap.addMarker( new MarkerOptions() .position(report) .icon(BitmapDescriptorFactory.fromResource(R.drawable.marker_green))); markerDataMap.put( reportMarker, new MarkerData( 453235, "Broken water pipe", "Pipe at indranagar is being broken since 3/Feb/2016", "13/feb/2016", "3/Feb/2016", 205)); report = new LatLng(12.9606028, 77.6460893); reportMarker = googleMap.addMarker( new MarkerOptions() .position(report) .icon(BitmapDescriptorFactory.fromResource(R.drawable.marker_red))); markerDataMap.put( reportMarker, new MarkerData( 658645, "Waste Dump", "Waste dump at kormangala is pending since 9/Feb/2016", "", "10/Feb/2016", 24)); report = new LatLng(12.9696028, 77.6479893); reportMarker = googleMap.addMarker( new MarkerOptions() .position(report) .icon(BitmapDescriptorFactory.fromResource(R.drawable.marker_red))); markerDataMap.put( reportMarker, new MarkerData( 235234, "No Street lights", "No street lights at indra nagar. Girls don't feel safe travelling at night. Please help us", "", "10/Feb/2016", 14)); googleMap.setOnMarkerClickListener(this); } }
public BitmapDescriptor getMarkerIcon() { BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker); if (getType().equals("N")) { if (isOpened()) { bitmapDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_opened); } else { bitmapDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_closed); } } return bitmapDescriptor; }
private void setSrcDistMarker() { srcMarker = gMap.addMarker( new MarkerOptions() .position(srcLatLng) .title("Starting Point") .icon(BitmapDescriptorFactory.fromResource(R.drawable.srcmarker))); distMarker = gMap.addMarker( new MarkerOptions() .position(distLatLng) .title("Destination Point") .icon(BitmapDescriptorFactory.fromResource(R.drawable.distmarker))); }
/** * This is where we can add markers or lines, add listeners or move the camera. * * <p>This should only be called once and when we are sure that {@link #mMap} is not null. */ private void setUpMap() { mapUI = mMap.getUiSettings(); mapUI.setZoomControlsEnabled(false); Intent viewRouteActivity = getIntent(); this.routeID = Integer.valueOf(viewRouteActivity.getStringExtra("routeID")); this.totalDistance = Float.valueOf(viewRouteActivity.getStringExtra("totalDistance")); this.avgSpeed = Float.valueOf(viewRouteActivity.getStringExtra("avgSpeed")); this.startTime = viewRouteActivity.getStringExtra("startTime"); this.endtime = viewRouteActivity.getStringExtra("endTime"); Cursor resultSet = dbHandler.getRoutePoints(this.routeID); if (resultSet != null && resultSet.moveToFirst()) { PolylineOptions rectOptions = new PolylineOptions().color(Color.BLUE).width(ROUTEWIDTH); LatLng routeStart = new LatLng(resultSet.getDouble(LATITUDE), resultSet.getDouble(LONGITUDE)); LatLng routeEnd = null; while (!resultSet.isAfterLast()) { rectOptions.add( routeEnd = new LatLng(resultSet.getDouble(LATITUDE), resultSet.getDouble(LONGITUDE))); resultSet.moveToNext(); } mMap.addPolyline(rectOptions); mMap.addMarker( new MarkerOptions() .position(routeStart) .icon(BitmapDescriptorFactory.fromResource(R.drawable.cycling)) .title(this.startTime)); mMap.addMarker( new MarkerOptions() .position(routeEnd) .icon(BitmapDescriptorFactory.fromResource(R.drawable.finish)) .title(this.endtime)); moveCamera(routeStart, DEFAULTZOOM); resultSet.close(); } else { // TODO: some error, no route points for route } }
@Override public void onMapReady(GoogleMap map) { LatLng dosDeMayo = new LatLng(-12.046374, -77.0427934); LatLng bolognesi = new LatLng(-12.06030544, -77.0415616); LatLng posRandom1 = new LatLng(-12.02244752, -77.05248356); LatLng posRandom2 = new LatLng(-12.01816614, -77.05336332); LatLng posReu = new LatLng(-12.02478756, -77.05208659); LatLng myPosLL = new LatLng(-12.01712464, -77.05044508); // Markers // map.addMarker(new MarkerOptions().position(dosDeMayo).title("Pepito")); map.addMarker( new MarkerOptions() .icon(BitmapDescriptorFactory.fromResource(R.drawable.icon_user_16)) .position(dosDeMayo) .title("Fulano")); map.addMarker( new MarkerOptions() .icon(BitmapDescriptorFactory.fromResource(R.drawable.icon_user_16)) .position(bolognesi) .title("Mengano")); map.addMarker( new MarkerOptions() .icon(BitmapDescriptorFactory.fromResource(R.drawable.icon_user_16)) .position(posRandom2) .title("Zutano")); map.addMarker( new MarkerOptions() .icon(BitmapDescriptorFactory.fromResource(R.drawable.icon_user_16)) .position(posRandom1) .title("Perengano")); map.addMarker( new MarkerOptions() .icon(BitmapDescriptorFactory.fromResource(R.drawable.icon_grupo_16)) .position(posReu) .title("Evento 1") .snippet("31 de octubre")); // Positions // map.moveCamera(CameraUpdateFactory.newLatLng(dosDeMayo)); CameraPosition myPos = new CameraPosition.Builder().target(myPosLL).zoom(14).build(); mMap.animateCamera(CameraUpdateFactory.newCameraPosition(myPos)); // Busca mi posición LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); Criteria criteria = new Criteria(); String provider = locationManager.getBestProvider(criteria, true); // checkPermission(); // Fin mi posicion }
private void setMarkersOptions(Location loc) { boolean visible = true; if (markersOnMap == null) { markersOnMap = new ArrayList<Marker>(); } for (Task task : TaskList.getInstance(getApplicationContext()).getTasks()) { LatLng temp = getLatLngIfPossible(task.getLocation()); if (temp != null) { Location tloc = new Location(task.getLocation()); tloc.setLatitude(temp.latitude); tloc.setLongitude(temp.longitude); float dist = tloc.distanceTo(loc); Marker tempMarker = map.addMarker( new MarkerOptions() .position(temp) .visible(visible) .title(String.valueOf(task.getTask_id())) .icon(BitmapDescriptorFactory.fromResource(R.drawable.marke_65px))); if (dist > sbRadOuter.getProgress() * 100) { tempMarker.setVisible(false); } markersOnMap.add(tempMarker); } } }
public static Marker placeRobotMarkerOnMap( Marker marker, GoogleMap mMap, LatLng location, boolean animateTheCamera, Resources res, Context context) { try { marker.remove(); } catch (Exception e) { e.printStackTrace(); Log.e("MapUtilities", "placeMarkerOnMapUserLatLng: Could not remove Robots Marker"); } MarkerOptions m = new MarkerOptions() .position(location) .icon(BitmapDescriptorFactory.fromResource(R.drawable.robot)) .title("ROBOT"); marker = mMap.addMarker(m); marker.showInfoWindow(); if (animateTheCamera) animateCameraLatLng(mMap, location, res); Log.d("ROBOT_LOCATION", "Latitude: " + location.latitude + " Longitude: " + location.longitude); // Toast.makeText(context,"Latitude: " +location.latitude+" Longitude: // "+location.longitude,Toast.LENGTH_LONG).show(); return marker; }
public void addMaker(Clinic clinic) { BitmapDescriptor icon = null; try { icon = BitmapDescriptorFactory.fromResource(R.drawable.s7apoint); } catch (Exception exception) { } try { double latitude = Double.parseDouble(clinic.latitude); double longitude = Double.parseDouble(clinic.longitude); LatLng mLocation = new LatLng(latitude, longitude); GoogleMap googleMap = getMap(); MarkerOptions myMarkerOptions = new MarkerOptions(); myMarkerOptions.position(mLocation); myMarkerOptions.title(clinic.name); myMarkerOptions.snippet(clinic.address); if (icon != null) { myMarkerOptions.icon(icon); } com.google.android.gms.maps.model.Marker marker = googleMap.addMarker(myMarkerOptions); } catch (Exception exception) { } }
// takes map param and injects a a new court marker public void populateMapWithModel( GoogleMap mMap, final Context mContext, HashMap<String, SearchItemModel> markerMap) { int randomColor = 0; if (gamesExist()) { randomColor = 1; } markyMarker = mMap.addMarker( new MarkerOptions() .position(getCourtLatLng()) .draggable(false) .title(name) .snippet(games + " games active within 24hrs") .icon(BitmapDescriptorFactory.fromResource(AppDefines.court_icons[randomColor]))); // .icon(BitmapDescriptorFactory.defaultMarker(randomColor))); // connects HashMap to SearchItemModel/Map marker markerMap.put(markyMarker.getId(), this); // server request // Game game = new Game(name); // searchLocation(game, mContext); }
@Override public void onDriverReady(List<Loadshopping> drivers) { if (drivers.isEmpty()) { Snackbar.make( findViewById(R.id.tab_container), getString(R.string.snackbar_nodrivernearby), Snackbar.LENGTH_LONG) .show(); } else { driverHashMap = new HashMap<>(); for (Loadshopping driver : drivers) { String driverFullName = Hex.decode(driver.getFullName()); LatLng driverLatLng = new LatLng(Double.valueOf(driver.getLatitude()), Double.valueOf(driver.getLongitude())); Marker marker = mMap.addMarker( new MarkerOptions() .title(driverFullName) .position(driverLatLng) .icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_green_marker_filled))); driverHashMap.put(marker, driver); } } }
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_maps_daus); MapFragment mapFragment = (MapFragment) getFragmentManager().findFragmentById(R.id.maps); mapFragment.getMapAsync(this); try { initializeMaps(); gMaps.addMarker( new MarkerOptions() .icon(BitmapDescriptorFactory.fromResource(R.drawable.wisataa)) .position(new LatLng(5.559382, 95.321629)) .visible(true) .title("Nasi Goreng Daus")); gMaps.setMyLocationEnabled(true); CameraPosition cameraPosition = new CameraPosition.Builder().target(new LatLng(5.484702, 95.227189)).zoom(10).build(); gMaps.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)); gMaps.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition), 2000, null); } catch (Exception e) { } }
@Override public void onResume() { if (getMap() != null && getView() != null) { // Ponemos que inicie el mapa en el Kiosko de Surbus getMap().moveCamera(CameraUpdateFactory.newLatLng(coordenadas)); getMap().setMapType(GoogleMap.MAP_TYPE_HYBRID); getMap().setMyLocationEnabled(true); getMap().setOnMyLocationChangeListener(this); getMap().moveCamera(CameraUpdateFactory.zoomTo(15)); getMap() .setOnMarkerClickListener( new OnMarkerClickListener() { @Override public boolean onMarkerClick(Marker marker) { synchronized (DataStorage.paradas) { Parada p = DataStorage.paradas.get(Integer.parseInt(marker.getTitle())); DialogFragment f = MostrarInfoParada.newInstance(p.getId()); f.show(getActivity().getSupportFragmentManager(), "Info"); } return true; } }); bitmapParada = BitmapDescriptorFactory.fromResource(R.drawable.bus_stop); buscarParadas(); } super.onResume(); }
private MarkerOptions getMarkerOption(LatLng coordinate, String stationName) { MarkerOptions markerOptions = new MarkerOptions(); markerOptions.position(coordinate); markerOptions.title(stationName); markerOptions.icon(BitmapDescriptorFactory.fromResource(R.drawable.train)); return markerOptions; }
/** Sets the MapView's initial properties. */ protected void setupMap() { gmap.setMapType(GoogleMap.MAP_TYPE_NONE); // Hide Google tiles gmap.setMyLocationEnabled(true); // Disable UI components UiSettings ui = gmap.getUiSettings(); ui.setAllGesturesEnabled(true); ui.setMyLocationButtonEnabled(true); ui.setZoomControlsEnabled(false); // Add custom map overlay overlay = gmap.addGroundOverlay( new GroundOverlayOptions() .image(BitmapDescriptorFactory.fromResource(R.drawable.map_overlay)) .positionFromBounds(OVERLAY_BOUNDS) .zIndex(1.0f)); gmap.addPolygon(createMapShade()); // Shade out of bounds areas gmap.setOnInfoWindowClickListener(this); // Center on Lancaster centerOnHome(); }
@Override protected void onBeforeClusterItemRendered(Case item, MarkerOptions markerOptions) { markerOptions .icon(BitmapDescriptorFactory.fromResource(R.drawable.pin)) .title(item.building_name) .snippet(item.address); }
/** Displays current location with information about timezone etc. */ private void displayCurrentLocation() { final double[] loc = getLocation(); if (loc == null) { Toast.makeText(this, "Could not fetch location", Toast.LENGTH_LONG).show(); return; } final View infoWindow = LayoutInflater.from(this).inflate(R.layout.infowindow, null); mMap.setInfoWindowAdapter( new GoogleMap.InfoWindowAdapter() { @Override public View getInfoWindow(Marker marker) { return null; } @Override public View getInfoContents(Marker marker) { populateInfoWindow(loc, infoWindow); return infoWindow; } }); Marker me = mMap.addMarker( new MarkerOptions() .position(new LatLng(loc[0], loc[1])) .title("Current Location") .icon(BitmapDescriptorFactory.fromResource(android.R.drawable.star_on))); mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(loc[0], loc[1]), 5)); me.showInfoWindow(); }
public void customAddMarker(LatLng latLng, String title, String snippet) { MarkerOptions options = new MarkerOptions(); options.position(latLng).title(title).snippet(snippet).draggable(false); options.icon(BitmapDescriptorFactory.fromResource(R.drawable.pin)); marker = map.addMarker(options); }
// 在地圖加入指定位置與標題的標記 private void addMarker(LatLng place, String title, String context) { BitmapDescriptor icon = BitmapDescriptorFactory.fromResource(R.mipmap.ic_launcher); MarkerOptions markerOptions = new MarkerOptions(); markerOptions.position(place).title(title).snippet(context).icon(icon); mMap.addMarker(markerOptions); }
@Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap; mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(StartLat, EndLng), 8.1f)); // Instantiates a new Polyline object and adds points to define a rectangle Log.d("Start lat 1 ", String.valueOf(StartLat)); Log.d("End lat 1 ", String.valueOf(EndLat)); Log.d("Start lng 1 ", String.valueOf(StartLng)); Log.d("End lng 1 ", String.valueOf(EndLng)); PolylineOptions rectOptions = new PolylineOptions() .add(new LatLng(StartLat, StartLng)) .add(new LatLng(EndLat, EndLng)) .color(R.color.primaryColor) .width(6); // North of the previous point, but at the same longitude // Closes the polyline. mMap.getUiSettings().setMapToolbarEnabled(false); mMap.getUiSettings().setZoomControlsEnabled(true); mMap.getUiSettings().setZoomGesturesEnabled(true); // Get back the mutable Polyline Polyline polyline = mMap.addPolyline(rectOptions); final Marker markerZero = mMap.addMarker( new MarkerOptions() .position(new LatLng(StartLat, StartLng)) .icon(BitmapDescriptorFactory.fromResource(R.drawable.pindriver)) .snippet(FromRegionEnName_Str) .title(FromEmirateEnName_Str)); mMap.addMarker( new MarkerOptions() .position(new LatLng(EndLat, EndLng)) .icon(BitmapDescriptorFactory.fromResource(R.drawable.pindriver)) .snippet(ToRegionEnName_Str) .title(ToEmirateEnName_Str)); markerZero.showInfoWindow(); }
private void setOverlay() { map.addMarker( new MarkerOptions() .position(latLng1) .icon(BitmapDescriptorFactory.fromResource(R.drawable.marker)) .title(this.getString(R.string.local_desejado)) .snippet(endereco)); }
public static void placeMarkerOnMapLatLng( GoogleMap mMap, LatLng location, String markerInfo, boolean visited, boolean systemDefined, Resources res) { if (visited) { if (systemDefined) mMap.addMarker( new MarkerOptions() .position(location) .title(markerInfo) .flat(false) .icon(BitmapDescriptorFactory.fromResource(R.drawable.system_marker_blue))) .showInfoWindow(); else mMap.addMarker( new MarkerOptions() .position(location) .title(markerInfo) .flat(false) .icon(BitmapDescriptorFactory.fromResource(R.drawable.grey_marker))) .showInfoWindow(); } else { if (systemDefined) mMap.addMarker( new MarkerOptions() .position(location) .title(markerInfo) .flat(false) .icon(BitmapDescriptorFactory.fromResource(R.drawable.system_marker_green))) .showInfoWindow(); else mMap.addMarker( new MarkerOptions() .position(location) .title(markerInfo) .flat(false) .icon(BitmapDescriptorFactory.fromResource(R.drawable.green_marker))) .showInfoWindow(); } animateCameraLatLng(mMap, location, res); }
/** Add Marker to Map. */ private void addMarkerToMap() { droneMarker = flightMapFragment.mMap.addMarker( new MarkerOptions() .anchor((float) 0.5, (float) 0.5) .position(new LatLng(0, 0)) .icon(BitmapDescriptorFactory.fromResource(R.drawable.quad)) .visible(false) .flat(true)); }
@Override public void chooseMarker(final MarkerOptions markerOptions, final ClusterPoint clusterPoint) { final Equipement bicloo = (Equipement) clusterPoint.getPointAtOffset(0).getTag(); final BitmapDescriptor icon = BitmapDescriptorFactory.fromResource(Equipement.Type.TYPE_BICLOO.getMapPin()); final String title = bicloo.getNom(); markerOptions.icon(icon); markerOptions.title(title); }
private void addMapOverlays() { for (Shelf shelf : SHELVES) { GroundOverlayOptions ovr = new GroundOverlayOptions() .image(BitmapDescriptorFactory.fromResource(R.drawable.shelf)) .position(shelf.pos, shelf.width, shelf.length); mMap.addGroundOverlay(ovr); } }
public void setimage_location(Location location) { if (mPositionMarker == null) { mPositionMarker = myMap.addMarker( new MarkerOptions() .flat(true) .icon(BitmapDescriptorFactory.fromResource(R.mipmap.truckicon)) .anchor(0.5f, 0.5f) .position(new LatLng(location.getLatitude(), location.getLongitude()))); } }
private Marker addMarker( GoogleMap map, String title, String snippet, int drawableId, LatLng position) { return map.addMarker( new MarkerOptions() .title(title) .snippet(snippet) .icon(BitmapDescriptorFactory.fromResource(drawableId)) .position(position) .anchor(0.5f, 1.0f)); }
private void setUpMap() { mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(NEWARK, 11)); mGroundOverlay = mMap.addGroundOverlay( new GroundOverlayOptions() .image(BitmapDescriptorFactory.fromResource(R.drawable.newark_nj_1922)) .anchor(0, 1) .position(NEWARK, 8600f, 6500f)); mTransparencyBar.setOnSeekBarChangeListener(this); }