Java Code Examples for com.google.android.gms.maps.model.Marker#getPosition()
The following examples show how to use
com.google.android.gms.maps.model.Marker#getPosition() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GglMapAiLineManager.java From FimiX8-RE with MIT License | 6 votes |
public void onMarkerDragEnd(Marker marker) { MapPointLatLng mp = (MapPointLatLng) marker.getTag(); marker.setIcon(this.gdCustemMarkerView.createMapPioView(this.context, R.drawable.x8_img_ai_line_inreterst_max1, mp.altitude, mp.nPos, false, false)); MapPointLatLng tmp = (MapPointLatLng) marker.getTag(); tmp.isInrertestPointActive = true; tmp.latitude = marker.getPosition().latitude; tmp.longitude = marker.getPosition().longitude; int i = 0; for (MapPointLatLng mpl : this.mMapPointList) { if (mpl.mInrertestPoint != null && tmp == mpl.mInrertestPoint) { mpl.setAngle(getPointAngle(mpl, tmp)); changePointMarker((Marker) this.mMarkerList.get(i), mpl, false); } i++; } }
Example 2
Source File: MapViewPager.java From MapViewPager with Apache License 2.0 | 6 votes |
private GoogleMap.OnMarkerClickListener createMarkerClickListenerSingle(final Adapter adapter) { return new GoogleMap.OnMarkerClickListener() { @Override public boolean onMarkerClick(Marker marker) { for (int i = 0; i < adapter.getCount(); i++) { CameraPosition cp = adapter.getCameraPosition(i); if (cp != null && cp.target != null && cp.target.latitude == marker.getPosition().latitude && cp.target.longitude == marker.getPosition().longitude) { viewPager.setCurrentItem(i); marker.showInfoWindow(); return true; } } return false; } }; }
Example 3
Source File: GoogleMapShapeMarkers.java From geopackage-android-map with MIT License | 5 votes |
/** * Polygon add a marker in the list of markers to where it is closest to the * the surrounding points * * @param marker marker * @param markers list of markers */ public static void addMarkerAsPolygon(Marker marker, List<Marker> markers) { LatLng position = marker.getPosition(); int insertLocation = markers.size(); if (markers.size() > 2) { double[] distances = new double[markers.size()]; insertLocation = 0; distances[0] = SphericalUtil.computeDistanceBetween(position, markers.get(0).getPosition()); for (int i = 1; i < markers.size(); i++) { distances[i] = SphericalUtil.computeDistanceBetween(position, markers.get(i).getPosition()); if (distances[i] < distances[insertLocation]) { insertLocation = i; } } int beforeLocation = insertLocation > 0 ? insertLocation - 1 : distances.length - 1; int afterLocation = insertLocation < distances.length - 1 ? insertLocation + 1 : 0; if (distances[beforeLocation] > distances[afterLocation]) { insertLocation = afterLocation; } } markers.add(insertLocation, marker); }
Example 4
Source File: MapViewPager.java From MapViewPager with Apache License 2.0 | 5 votes |
private GoogleMap.OnMarkerClickListener createMarkerClickListenerMulti(final MultiAdapter adapter) { return new GoogleMap.OnMarkerClickListener() { @Override public boolean onMarkerClick(Marker marker) { for (int page = 0; page < adapter.getCount(); page++) { if (adapter.getCameraPositions(page) != null) { for (int i = 0; i < adapter.getCameraPositions(page).size(); i++) { CameraPosition cp = adapter.getCameraPositions(page).get(i); if (cp != null && cp.target != null && cp.target.latitude == marker.getPosition().latitude && cp.target.longitude == marker.getPosition().longitude) { if (marker.isInfoWindowShown()) { // this doesn't seem to work !! viewPager.setCurrentItem(page); return true; } else { viewPager.setCurrentItem(page); map.animateCamera(CameraUpdateFactory.newCameraPosition(cp)); marker.showInfoWindow(); return true; } } } } } return false; } }; }
Example 5
Source File: EstablishmentInteractorImpl.java From Saude-no-Mapa with MIT License | 5 votes |
@Override public void animateMarketToTop(GoogleMap map, Marker marker, double mapHeight) { double dpPerdegree = 256.0 * Math.pow(2, 15) / 170.0; double screen_height_30p = 15.0 * mapHeight / 100.0; double degree_30p = screen_height_30p / dpPerdegree; LatLng latLng = marker.getPosition(); LatLng centerlatlng = new LatLng(latLng.latitude - degree_30p, latLng.longitude); map.animateCamera(CameraUpdateFactory.newLatLngZoom(centerlatlng, 15), 500, null); }
Example 6
Source File: EmergencyInteractorImpl.java From Saude-no-Mapa with MIT License | 5 votes |
@Override public void animateMarketToTop(GoogleMap map, Marker marker, double mapHeight) { double dpPerdegree = 256.0 * Math.pow(2, 15) / 170.0; double screen_height_30p = 15.0 * mapHeight / 100.0; double degree_30p = screen_height_30p / dpPerdegree; LatLng latLng = marker.getPosition(); LatLng centerlatlng = new LatLng(latLng.latitude - degree_30p, latLng.longitude); map.animateCamera(CameraUpdateFactory.newLatLngZoom(centerlatlng, 15), 500, null); }
Example 7
Source File: GeofieldFragment.java From mobile-android-survey-app with MIT License | 5 votes |
@Override public void onMarkerDragEnd(Marker marker) { if (marker.getPosition() != null) { Log.i(this, "onMarkerDragEnd %f,%f", marker.getPosition().latitude, marker.getPosition().longitude); setLocation(marker.getPosition().latitude, marker.getPosition().longitude, false); } }
Example 8
Source File: HRMarkerAnimation.java From HRCarMarkerAnimation with MIT License | 4 votes |
public void animateMarker(final Location destination, final Location oldLocation, final Marker marker) { if (marker != null) { final LatLng startPosition = marker.getPosition(); final LatLng endPosition = new LatLng(destination.getLatitude(), destination.getLongitude()); if (valueAnimator != null) valueAnimator.end(); final Utilities.LatLngInterpolator latLngInterpolator = new Utilities.LatLngInterpolator.LinearFixed(); valueAnimator = ValueAnimator.ofFloat(0, 1); valueAnimator.setDuration(animationDuration); // duration 1 second valueAnimator.setInterpolator(new LinearInterpolator()); valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { try { float v = animation.getAnimatedFraction(); LatLng newPosition = latLngInterpolator.interpolate(v, startPosition, endPosition); marker.setPosition(newPosition); //marker.setRotation(computeRotation(v, startRotation, destination.getBearing())); marker.setRotation(Utilities.computeRotation(v, marker.getRotation(), (float)Utilities.bearingBetweenLocations(startPosition, newPosition))); marker.setAnchor(0.5f, 0.5f); marker.setFlat(true); // add new location into old location updateLocation.onUpdatedLocation(destination); //when marker goes out from screen it automatically move into center if (googleMap!=null){ if (!Utilities.isMarkerVisible(googleMap,newPosition)){ googleMap.animateCamera(CameraUpdateFactory .newCameraPosition(new CameraPosition.Builder() .target(newPosition) .zoom(googleMap.getCameraPosition().zoom) .build())); }else { try { googleMap.animateCamera(CameraUpdateFactory .newCameraPosition(new CameraPosition.Builder() .target(newPosition) .tilt(0) .zoom(googleMap.getCameraPosition().zoom) .build())); }catch (Exception e){ e.printStackTrace(); } } } } catch (Exception ex) { ex.printStackTrace(); // handle exception here } } }); valueAnimator.start(); } }
Example 9
Source File: GoogleMapShapeMarkers.java From geopackage-android-map with MIT License | 4 votes |
/** * Polyline add a marker in the list of markers to where it is closest to * the the surrounding points * * @param marker marker * @param markers list of markers */ public static void addMarkerAsPolyline(Marker marker, List<Marker> markers) { LatLng position = marker.getPosition(); int insertLocation = markers.size(); if (markers.size() > 1) { double[] distances = new double[markers.size()]; insertLocation = 0; distances[0] = SphericalUtil.computeDistanceBetween(position, markers.get(0).getPosition()); for (int i = 1; i < markers.size(); i++) { distances[i] = SphericalUtil.computeDistanceBetween(position, markers.get(i).getPosition()); if (distances[i] < distances[insertLocation]) { insertLocation = i; } } Integer beforeLocation = insertLocation > 0 ? insertLocation - 1 : null; Integer afterLocation = insertLocation < distances.length - 1 ? insertLocation + 1 : null; if (beforeLocation != null && afterLocation != null) { if (distances[beforeLocation] > distances[afterLocation]) { insertLocation = afterLocation; } } else if (beforeLocation != null) { if (distances[beforeLocation] >= SphericalUtil .computeDistanceBetween(markers.get(beforeLocation) .getPosition(), markers.get(insertLocation) .getPosition())) { insertLocation++; } } else { if (distances[afterLocation] < SphericalUtil .computeDistanceBetween(markers.get(afterLocation) .getPosition(), markers.get(insertLocation) .getPosition())) { insertLocation++; } } } markers.add(insertLocation, marker); }
Example 10
Source File: GoogleMapUtis.java From Airbnb-Android-Google-Map-View with MIT License | 4 votes |
public static String encodeMarkerForDirection(Marker marker) { return marker.getPosition().latitude + "," + marker.getPosition().longitude; }
Example 11
Source File: GeofieldFragment.java From mobile-android-survey-app with MIT License | 4 votes |
@Override public void onMarkerDragStart(Marker marker) { if (marker.getPosition() != null) { Log.i(this, "onMarkerDragStart %f,%f", marker.getPosition().latitude, marker.getPosition().longitude); } }
Example 12
Source File: SaveStateDemoActivity.java From android-samples with Apache License 2.0 | 4 votes |
@Override public void onMarkerDragEnd(Marker marker) { mMarkerPosition = marker.getPosition(); }
Example 13
Source File: DefaultClusterRenderer.java From android-maps-utils with Apache License 2.0 | 4 votes |
private MarkerWithPosition(Marker marker) { this.marker = marker; position = marker.getPosition(); }