@Override public void updateLocationMarker(Location location) { if (locationChangedListener != null) { currentUserLocation = location; locationChangedListener.onLocationChanged(location); } // Update clickable area LatLng userPosition = getUserLocation(location); if (userPositionClickArea == null) { MarkerOptions markerOptions = new MarkerOptions(); markerOptions.position(userPosition); markerOptions.anchor(0.4f, 0.4f); // strange google maps bug markerOptions.icon(BitmapDescriptorFactory.fromBitmap(clickableBitmap)); userPositionClickArea = googleMap.addMarker(markerOptions); } else { userPositionClickArea.setPosition(userPosition); } if (userPositionClickArea2 == null) { MarkerOptions markerOptions = new MarkerOptions(); markerOptions.position(userPosition); markerOptions.anchor(0.6f, 0.6f); // strange google maps bug markerOptions.icon(BitmapDescriptorFactory.fromBitmap(clickableBitmap)); userPositionClickArea2 = googleMap.addMarker(markerOptions); } else { userPositionClickArea2.setPosition(userPosition); } }
@Override protected void onPostExecute(String result) { Log.d("TAG", "Download task onpost"); JSONObject jObject; ArrayList<ArrayList<String>> plan = new ArrayList<>(); ArrayList<ArrayList<String>> step_dis = new ArrayList<>(); ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>(); Log.d("TAG", "switch mode=" + mode); try { map.clear(); jObject = new JSONObject(result); RoutesTextJSONParser par = new RoutesTextJSONParser(); summary = par.parse(jObject, "SUMMARY"); sep_distance = par.parse(jObject, "PLACE_NAVI_DISTANCE"); // in meters sep_duration = par.parse(jObject, "PLACE_NAVI_DURATION"); // in seconds Log.d("TAG", "Size of summary" + String.valueOf(summary.size())); Log.d("TAG", "Size of sep_dis" + String.valueOf(sep_distance.size())); Log.d("TAG", "Size of sep_dur" + String.valueOf(sep_duration.size())); for (int i = 0; i < summary.size(); i++) { Log.d("TAG", "summary=" + summary.get(i)); Log.d("TAG", "sep_dis=" + sep_distance.get(i)); Log.d("TAG", "sep_dur=" + sep_duration.get(i)); } // parse 出文字指示路段 plan = par.parseroad(jObject, 0, "PLACE_NAVI_TEXT"); Log.d("TAG", "PLACE_NAVI_TEXT size:" + plan.size()); // parse出每一個step的distance step_dis = par.parseroad(jObject, 0, "PLACE_NAVI_STEPS_DIS"); Log.d("TAG", "step_dis size:" + step_dis.size()); bindtext(plan, step_dis); getMap(result); MarkerOptions dest_options = new MarkerOptions(); dest_options.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)); dest_options.position(XY); dest_options.title("終點:" + ret_place_Name.get(0)); map.addMarker(dest_options); Log.d("TAG", "marker"); if (loc_marker != null) { loc_marker.remove(); } MarkerOptions pos_options = new MarkerOptions(); pos_options.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED)); pos_options.position(pos); pos_options.title("目前位置"); loc_marker = map.addMarker(pos_options); } catch (Exception e) { e.printStackTrace(); } sum.setText(summary.get(0)); dis_dur.setText(sep_distance.get(0) + "/" + sep_duration.get(0)); }
private void drawStartEndMarkers() { for (int i = 0; i < markerPoints.size(); i++) { MarkerOptions opt = new MarkerOptions(); opt.position(markerPoints.get(i)); if (i == 0) { opt.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)); } else if (i == 1) { opt.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED)); } // Add new marker to the Google Map Android API V2 map.addMarker(opt); } }
private MarkerOptions createMarker(ReadableMap markerJson) { MarkerOptions options = new MarkerOptions(); options.position( new LatLng( markerJson.getMap("coordinates").getDouble("lat"), markerJson.getMap("coordinates").getDouble("lng"))); if (markerJson.hasKey("title")) { options.title(markerJson.getString("title")); } if (markerJson.hasKey("color")) { options.icon(BitmapDescriptorFactory.defaultMarker((float) markerJson.getDouble("color"))); } if (markerJson.hasKey("snippet")) { options.snippet(markerJson.getString("snippet")); } if (markerJson.hasKey("icon")) { String varName = ""; ReadableType iconType = markerJson.getType("icon"); if (iconType.compareTo(ReadableType.Map) >= 0) { ReadableMap icon = markerJson.getMap("icon"); try { int resId = getResourceDrawableId(icon.getString("uri")); Bitmap image = BitmapFactory.decodeResource(reactContext.getResources(), resId); options.icon( BitmapDescriptorFactory.fromBitmap( Bitmap.createScaledBitmap( image, icon.getInt("width"), icon.getInt("height"), true))); } catch (Exception e) { varName = icon.getString("uri"); } } else if (iconType.compareTo(ReadableType.String) >= 0) { varName = markerJson.getString("icon"); } if (!varName.equals("")) { // Changing marker icon to use resource int resourceValue = getResourceDrawableId(varName); Log.i(REACT_CLASS, varName + markerJson.toString()); options.icon(BitmapDescriptorFactory.fromResource(resourceValue)); } } if (markerJson.hasKey("anchor")) { ReadableArray anchor = markerJson.getArray("anchor"); options.anchor((float) anchor.getDouble(0), (float) anchor.getDouble(1)); } return options; }
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) { } }
@Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap; mMap.setMyLocationEnabled(true); Bundle extras = getIntent().getExtras(); float[] lats = {}, lngs = {}; String[] titles = {}, snippets = {}; int[] beers = {}; if (null != extras) { lats = extras.getFloatArray("Latitudes"); lngs = extras.getFloatArray("Longitudes"); titles = extras.getStringArray("Titles"); snippets = extras.getStringArray("Snippets"); beers = extras.getIntArray("Beers"); } googleMap.setInfoWindowAdapter(new CustomInfoWindowAdapter()); LatLng ll = null; for (int i = 0; i < titles.length; i++) { ll = new LatLng(lats[i], lngs[i]); MarkerOptions mark = new MarkerOptions().position(ll).title(titles[i]).snippet(snippets[i]); // Other color if beer has been drunk. // The argument to defaultMarker() takes a float between 0-360.0, // check BitmapDescriptorFactory.HUE_*. // It is possible to create a BitmapDescriptor from drawables etc. BitmapDescriptor icon; if (i < beers.length && 0 < beers[i]) { icon = BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN); } else { icon = BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED); } mark.icon(icon); // Add a marker and set the number of beers drunk Marker marker = mMap.addMarker(mark); beerMap.put(marker, (beers.length > i ? beers[i] : 0)); } /* Add propellern */ BitmapDrawable bd = (BitmapDrawable) getResources().getDrawable(R.drawable.proppeller); Bitmap b = bd.getBitmap(); Bitmap bhalfsize = Bitmap.createScaledBitmap(b, b.getWidth() / 2, b.getHeight() / 2, false); MarkerOptions propellern = new MarkerOptions() .position(PROPELLERN) .icon(BitmapDescriptorFactory.fromBitmap(bhalfsize)); mMap.addMarker(propellern); /* See zoom */ if (null == ll || 1 < titles.length) { // Zoom from far 2.0 (zoomed out) to close 21.0 (zoomed in) mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(PROPELLERN, 12.2f)); } else { mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(ll, 12.2f)); } }
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; }
@Override protected void onBeforeClusterItemRendered(MarkerData item, MarkerOptions markerOptions) { super.onBeforeClusterItemRendered(item, markerOptions); imageView.setImageResource(item.getProfilePhoto()); Bitmap icon = iconGenerator.makeIcon(); markerOptions.icon(BitmapDescriptorFactory.fromBitmap(icon)).title(item.getName()); }
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); }
@Override protected void onBeforeClusterItemRendered(Case item, MarkerOptions markerOptions) { markerOptions .icon(BitmapDescriptorFactory.fromResource(R.drawable.pin)) .title(item.building_name) .snippet(item.address); }
private void markWaypoint(LatLng point) { // Create MarkerOptions object MarkerOptions markerOptions = new MarkerOptions(); markerOptions.position(point); markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE)); Marker marker = aMap.addMarker(markerOptions); mMarkers.put(mMarkers.size(), marker); }
/** * pointsに地点を追加するためのメソッド。追加する前に、パラメータのMarkerOptions (mo) が円に * 入っているかどうかに基づいて地点の色が変化。後、moと中心地点の距離がmoのsnippitに表示される。 * もし、ユーザーが中心地点が表示される前に地点を追加すると、snippitはアップデートされません。 * * @param mo 追加する地点 * @param context 現在のコンテクスト */ public static void addPoint(MarkerOptions mo, Context context) { MarkerOptions temp = mo; LatLng centerPtPos = centerPoint.getPosition(); // 追加する地点の色を決める if (calculationByDistance(mo.getPosition(), centerPtPos) < circleRadius) temp.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)); else temp.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED)); if (centerPoint.isVisible()) { double dtc = (double) Math.round(calculationByDistance(mo.getPosition(), centerPtPos) * 100000) / 100000; temp.snippet(context.getString(R.string.dist_to_center) + ": " + String.valueOf(dtc) + " km"); } points.add(0, temp); }
// Executed after the complete execution of doInBackground() method @Override protected void onPostExecute(List<HashMap<String, String>> list) { // Clears all the existing markers mGoogleMap.clear(); for (int i = 0; i < list.size(); i++) { // Creating a marker MarkerOptions markerOptions = new MarkerOptions(); // Getting a place from the places list HashMap<String, String> hmPlace = list.get(i); // Getting latitude of the place double lat = Double.parseDouble(hmPlace.get("lat")); // Getting longitude of the place double lng = Double.parseDouble(hmPlace.get("lng")); // Getting name String name = hmPlace.get("place_name"); // Getting vicinity String vicinity = hmPlace.get("vicinity"); // Getting the type String type = hmPlace.get("type"); // Getting the price_level String price = hmPlace.get("price"); int price_level = Integer.parseInt(price); int user_price = Integer.parseInt(price); LatLng latLng = new LatLng(lat, lng); // Setting the position for the marker markerOptions.position(latLng); // Setting the title for the marker. // This will be displayed on taping the marker markerOptions.title(name + " : " + vicinity); if (price_level <= user_price) { // Placing a marker on the touched position if (theRandomPlace != null && !theRandomPlace.equals(name)) { markerOptions.icon( BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE)); } Marker marker = mGoogleMap.addMarker(markerOptions); String id = marker.getId(); placeArray.add(name); addressArray.add(vicinity); locationArray.add(latLng); idArray.add(id); } } done_loading = 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); }
/** * 自動的に全ての地点の色とSnippitを変えるためのメソッド * * @param context 現在のコンテクスト */ public static void updatePointColors(Context context) { for (MarkerOptions m : points) { if (calculationByDistance(m.getPosition(), centerPoint.getPosition()) < circleRadius) m.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)); else m.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED)); if (centerPoint.isVisible()) { double distToCenter = (double) Math.round( calculationByDistance(m.getPosition(), centerPoint.getPosition()) * 100000) / 100000; m.snippet( context.getString(R.string.dist_to_center) + ": " + String.valueOf(distToCenter) + " km"); } } }
private MarkerOptions createMarkerOptions() { MarkerOptions options = new MarkerOptions().position(position); if (anchorIsSet) options.anchor(anchorX, anchorY); if (calloutAnchorIsSet) options.infoWindowAnchor(calloutAnchorX, calloutAnchorY); options.title(title); options.snippet(snippet); options.rotation(rotation); options.flat(flat); options.icon(getIcon()); return options; }
private void addMarker(double latitude, double longitude, double percent) { // create marker MarkerOptions marker = new MarkerOptions().position(new LatLng(latitude, longitude)).title("Hello Maps"); if (percent > 90) { // Changing marker icon marker.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED)); vertices.add(new Vertex(latitude, longitude)); } else if (percent > 50) // Changing marker icon marker.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_YELLOW)); else { // Changing marker icon marker.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)); } // adding marker googleMap.addMarker(marker); }
/** * Called before the marker for a Cluster is added to the map. The default implementation draws a * circle with a rough count of the number of items. */ protected void onBeforeClusterRendered(Cluster<T> cluster, MarkerOptions markerOptions) { int bucket = getBucket(cluster); BitmapDescriptor descriptor = mIcons.get(bucket); if (descriptor == null) { mColoredCircleBackground.getPaint().setColor(getColor(bucket)); descriptor = BitmapDescriptorFactory.fromBitmap(mIconGenerator.makeIcon(getClusterText(bucket))); mIcons.put(bucket, descriptor); } // TODO: consider adding anchor(.5, .5) (Individual markers will overlap more often) markerOptions.icon(descriptor); }
private void addToMap(Waypoint w) { MarkerOptions mo = new MarkerOptions(); if (w.name != null && w.name.length() > 0) mo.title(w.name); if (w.description != null && w.description.length() > 0) mo.snippet(w.description); mo.position(new LatLng(w.lat, w.lon)); mo.icon(BitmapDescriptorFactory.fromResource(R.drawable.pin1)); // TODO custom icons mo.draggable(true); Marker m = map.addMarker(mo); markers.add(m); waypoints.put(m.getId(), w); }
public void addMarker(Airplane airplane) { AirplanePosition position = airplane.getLastPosition(); LatLng location = new LatLng(position.getLatitude(), position.getLongitude()); float angle = (float) airplane.getHead() - map.getCameraPosition().bearing; MarkerOptions options = new MarkerOptions(); options.position(location); options.title(airplane.getHex()); options.icon(BitmapDescriptorFactory.fromBitmap(getAirplaneIcon(angle))); options.anchor(0.5f, 0.5f); Marker marker = map.addMarker(options); markers.add(marker); }
@Override protected void onPostExecute(List<Address> addresses) { if (addresses == null || addresses.size() == 0) { Toast.makeText(getBaseContext(), "No Location found", Toast.LENGTH_SHORT).show(); setProgressBarIndeterminateVisibility(false); return; } ViewMapFragment mMapFragment = (ViewMapFragment) getSupportFragmentManager().findFragmentByTag("map"); if (!searchMarkers.isEmpty()) { // Clears all the existing markers on the map for (Marker m : searchMarkers) { m.remove(); } searchMarkers.clear(); } // Adding Markers on Google Map for each matching address for (int i = 0; i < addresses.size(); i++) { Address address = (Address) addresses.get(i); // Creating an instance of GeoPoint, to display in Google Map LatLng latLng = new LatLng(address.getLatitude(), address.getLongitude()); String addressText = String.format( "%s, %s", address.getMaxAddressLineIndex() > 0 ? address.getAddressLine(0) : "", address.getCountryName()); MarkerOptions markerOptions = new MarkerOptions(); markerOptions.position(latLng); markerOptions.title(addressText); markerOptions.icon( BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)); searchMarkers.add(mMapFragment.mMap.addMarker(markerOptions)); // Locate the first location if (i == 0) mMapFragment.mMap.animateCamera(CameraUpdateFactory.newLatLng(latLng)); } querying = false; setProgressBarIndeterminateVisibility(false); }
@Override protected void onBeforeClusterItemRendered(HostBriefInfo host, MarkerOptions markerOptions) { String street = host.getStreet(); String snippet = host.getCity() + ", " + host.getProvince().toUpperCase(); if (street != null && street.length() > 0) { snippet = street + "<br/>" + snippet; } if (mLastDeviceLocation != null) { double distance = Tools.calculateDistanceBetween(host.getLatLng(), mLastDeviceLocation, mDistanceUnit); snippet += "<br/>" + getString(R.string.distance_from_current, (int) distance, mDistanceUnit); } markerOptions.title(host.getFullname()).snippet(snippet); markerOptions.icon(mSingleHostBitmapDescriptor); }
private void showCurrentMap(Double latitude, Double longitude) { LatLng curPoint = new LatLng(latitude, longitude); map.animateCamera(CameraUpdateFactory.newLatLngZoom(curPoint, 15)); map.setMapType(GoogleMap.MAP_TYPE_NORMAL); MarkerOptions marker = new MarkerOptions(); marker.position(new LatLng(latitude+0.001, longitude+0.001)); marker.title("은행 지점"); marker.snippet("잠실 지점입니다."); marker.draggable(true); marker.icon(BitmapDescriptorFactory.fromResource(R.drawable.bank)); map.addMarker(marker); }
@Override public void onMapLongClick(LatLng latlng) { // 既に追加マーカーを配置済みなら、前のマーカーを削除する if (mAddMarker != null) { mAddMarker.remove(); mAddMarker = null; } // マーカーを追加し、インフォウィンドウを表示する MarkerOptions options = new MarkerOptions(); options.position(latlng); BitmapDescriptor icon = BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE); options.icon(icon); options.title(getString(R.string.Marker_NotRegistered)); mAddMarker = mMap.addMarker(options); mAddMarker.showInfoWindow(); }
private void showRoute() { PolylineOptions rectOptions = new PolylineOptions(); LatLng latLng = null; for (RoutePoint point : route.getRoutePointList()) { latLng = new LatLng(point.getLatitude(), point.getLongitude()); rectOptions.add(latLng); } rectOptions.color(0xA00080FF); map.addPolyline(rectOptions); MarkerOptions endMarker = new MarkerOptions(); endMarker.position(latLng); String label = place != null ? place.getName() : "Parking Spot"; endMarker.title(label + " @ " + RouteCursorAdapter.getRouteTimeAgo(this, route)); endMarker.icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_launcher)); endMarker.anchor(0.5f, 0.5f); map.addMarker(endMarker); }
public MarkerOptions addMaker(double lat, double longitude, BitmapDescriptor icon) { try { LatLng mLocation = new LatLng(lat, longitude); GoogleMap googleMap = getMap(); MarkerOptions myMarkerOptions = new MarkerOptions(); myMarkerOptions.position(mLocation); if (icon != null) { myMarkerOptions.icon(icon); } googleMap.addMarker(myMarkerOptions); return myMarkerOptions; } catch (Exception exception) { } return null; }
@Override protected void onCreate(Bundle savedInstanceState) { Log.i(BOOTY, "onCreate called"); super.onCreate(savedInstanceState); getWindow() .setFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_main); manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); manager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, gpsListener()); manager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, gpsListener()); MapFragment mapFragment = (MapFragment) getFragmentManager().findFragmentById(R.id.map); map = mapFragment.getMap(); map.setOnInfoWindowClickListener(infoWindowClickListener()); map.setOnMarkerClickListener(markerClickListener()); map.setMyLocationEnabled(true); map.moveCamera(toMyPosition(null)); final BitmapDescriptor icon = BitmapDescriptorFactory.fromResource(R.drawable.small_chest); for (Bar bar : Bar.defaultBars) { MarkerOptions options = new MarkerOptions(); options.title(bar.title); options.position(bar.location); options.icon(icon); map.addMarker(options); } AndroidDeferredManager deferredManager = new AndroidDeferredManager(); deferredManager.setAutoSubmit(true); String username = getIntent().getStringExtra(SplashyActivity.USERNAME); myUser = User.fromName(username); Typeface piratey = Typeface.createFromAsset(getAssets(), "fonts/pirate_font.ttf"); ((TextView) findViewById(R.id.info_view)).setTypeface(piratey); ((TextView) findViewById(R.id.location_name)).setTypeface(piratey); ((TextView) findViewById(R.id.save_button)).setTypeface(piratey); ((TextView) findViewById(R.id.spinner_label)).setTypeface(piratey); setupSpinnerEntries((Spinner) findViewById(R.id.user_name)); }
@Override protected void onBeforeClusterRendered( Cluster<HostBriefInfo> cluster, MarkerOptions markerOptions) { if (clusterLocationStatus(cluster) == ClusterStatus.all) { int size = cluster.getSize(); BitmapDescriptor descriptor = mIcons.get(size); if (descriptor == null) { // Cache new bitmaps descriptor = BitmapDescriptorFactory.fromBitmap( mSingleLocationClusterIconGenerator.makeIcon(String.valueOf(size))); mIcons.put(size, descriptor); } markerOptions.icon(descriptor); } else { super.onBeforeClusterRendered(cluster, markerOptions); } }
// executes in UI thread @Override protected void onPostExecute(List<List<HashMap<String, String>>> result) { ArrayList<LatLng> points = null; PolylineOptions lineOptions = null; MarkerOptions markerOptions = new MarkerOptions(); // traversing through all the routes // lineOptions = new PolylineOptions(); for (int i = 0; i < result.size(); i++) { points = new ArrayList<LatLng>(); lineOptions = new PolylineOptions(); // fetching ith route List<HashMap<String, String>> path = result.get(i); // fetching points in the ith route for (int j = 0; j < path.size(); j++) { HashMap<String, String> point = path.get(j); double lat = Double.parseDouble(point.get("lat")); double lng = Double.parseDouble(point.get("lng")); LatLng position = new LatLng(lat, lng); Log.d(TAG, position.toString()); if ((j % 2 == 0) && (j != 0)) mMap.addMarker( markerOptions .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE)) .position(position) .title("latitude: " + lat + ", " + "longitude: " + lng)); points.add(position); } // adding all points in the route to lineOptions lineOptions.addAll(points); lineOptions.width(5); lineOptions.color(Color.BLUE); // mMap.addPolyline(lineOptions); } // draw polyline on map mMap.addPolyline(lineOptions); }
@Override public void onLocationChanged(Location location) { mLocation = location; // create marker MarkerOptions marker = new MarkerOptions() .position(new LatLng(mLocation.getLatitude(), mLocation.getLongitude())) .title("my location - kirma"); // Changing marker icon marker.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_ROSE)); // adding marker googleMap.addMarker(marker); CameraPosition cameraPosition = new CameraPosition.Builder() .target(new LatLng(mLocation.getLatitude(), mLocation.getLongitude())) .zoom(12) .build(); googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)); }