use of com.google.android.gms.maps.model.MarkerOptions in project Android-GoogleDirectionAndPlaceLibrary by akexorcist.
the class DirectionActivity1 method onCreate.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_direction_1);
mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(start, 15));
gd = new GoogleDirection(this);
gd.setOnDirectionResponseListener(new OnDirectionResponseListener() {
public void onResponse(String status, Document doc, GoogleDirection gd) {
mDoc = doc;
mMap.addPolyline(gd.getPolyline(doc, 3, Color.RED));
mMap.addMarker(new MarkerOptions().position(start).icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)));
mMap.addMarker(new MarkerOptions().position(end).icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)));
buttonAnimate.setVisibility(View.VISIBLE);
}
});
gd.setOnAnimateListener(new OnAnimateListener() {
public void onStart() {
textProgress.setVisibility(View.VISIBLE);
}
public void onProgress(int progress, int total) {
textProgress.setText(progress + " / " + total);
}
public void onFinish() {
buttonAnimate.setVisibility(View.VISIBLE);
textProgress.setVisibility(View.GONE);
}
});
textProgress = (TextView) findViewById(R.id.textProgress);
textProgress.setVisibility(View.GONE);
buttonRequest = (Button) findViewById(R.id.buttonRequest);
buttonRequest.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
v.setVisibility(View.GONE);
gd.setLogging(true);
gd.request(start, end, GoogleDirection.MODE_DRIVING);
}
});
buttonAnimate = (Button) findViewById(R.id.buttonAnimate);
buttonAnimate.setVisibility(View.GONE);
buttonAnimate.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
v.setVisibility(View.GONE);
gd.animateDirection(mMap, gd.getDirection(mDoc), GoogleDirection.SPEED_FAST, true, false, true, false, null, false, true, null);
}
});
}
use of com.google.android.gms.maps.model.MarkerOptions in project Android-GoogleDirectionAndPlaceLibrary by akexorcist.
the class DirectionActivity3 method onCreate.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_direction_1);
mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(start, 15));
gd = new GoogleDirection(this);
gd.setOnDirectionResponseListener(new OnDirectionResponseListener() {
public void onResponse(String status, Document doc, GoogleDirection gd) {
mDoc = doc;
mMap.addPolyline(gd.getPolyline(doc, 3, Color.RED));
buttonAnimate.setVisibility(View.VISIBLE);
}
});
gd.setOnAnimateListener(new OnAnimateListener() {
public void onStart() {
textProgress.setVisibility(View.VISIBLE);
}
public void onProgress(int progress, int total) {
textProgress.setText((int) ((float) progress / total * 100) + "% / 100%");
}
public void onFinish() {
buttonAnimate.setVisibility(View.VISIBLE);
textProgress.setVisibility(View.GONE);
}
});
textProgress = (TextView) findViewById(R.id.textProgress);
textProgress.setVisibility(View.GONE);
buttonRequest = (Button) findViewById(R.id.buttonRequest);
buttonRequest.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
v.setVisibility(View.GONE);
gd.setLogging(true);
gd.request(start, end, GoogleDirection.MODE_DRIVING);
}
});
buttonAnimate = (Button) findViewById(R.id.buttonAnimate);
buttonAnimate.setVisibility(View.GONE);
buttonAnimate.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
v.setVisibility(View.GONE);
gd.animateDirection(mMap, gd.getDirection(mDoc), GoogleDirection.SPEED_VERY_SLOW, true, false, true, true, new MarkerOptions().icon(BitmapDescriptorFactory.fromResource(R.drawable.car)), true, false, null);
}
});
}
use of com.google.android.gms.maps.model.MarkerOptions in project Android-GoogleDirectionAndPlaceLibrary by akexorcist.
the class PlaceActivity2 method onCreate.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_place_2);
mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(latitude, longitude), 15));
gp = new GooglePlaceSearch(ApiKey);
gp.setOnPlaceResponseListener(new OnPlaceResponseListener() {
public void onResponse(String status, ArrayList<ContentValues> arr_data, Document doc) {
Toast.makeText(getApplicationContext(), status, Toast.LENGTH_SHORT).show();
if (status.equals(GooglePlaceSearch.STATUS_OK)) {
for (int i = 0; i < arr_data.size(); i++) {
String title = arr_data.get(i).getAsString(GooglePlaceSearch.PLACE_NAME);
double lat = arr_data.get(i).getAsDouble(GooglePlaceSearch.PLACE_LATITUDE);
double lng = arr_data.get(i).getAsDouble(GooglePlaceSearch.PLACE_LONGITUDE);
LatLng pos = new LatLng(lat, lng);
mMap.addMarker(new MarkerOptions().position(pos).title(title));
}
}
}
});
gp.getNearby(latitude, longitude, radius, type, language);
//gp.getRadarSearch(latitude, longitude, radius, type, language, false);
}
use of com.google.android.gms.maps.model.MarkerOptions in project Android-GoogleDirectionAndPlaceLibrary by akexorcist.
the class SimpleDirection method onCreate.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_simple_direction);
mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(start, 15));
gd = new GoogleDirection(this);
gd.setOnDirectionResponseListener(new OnDirectionResponseListener() {
public void onResponse(String status, Document doc, GoogleDirection gd) {
mDoc = doc;
mMap.addPolyline(gd.getPolyline(doc, 3, Color.RED));
mMap.addMarker(new MarkerOptions().position(start).icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)));
mMap.addMarker(new MarkerOptions().position(end).icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)));
}
});
buttonRequest = (Button) findViewById(R.id.buttonRequest);
buttonRequest.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
v.setVisibility(View.GONE);
gd.setLogging(true);
gd.request(start, end, GoogleDirection.MODE_DRIVING);
}
});
}
use of com.google.android.gms.maps.model.MarkerOptions in project Android-GoogleDirectionAndPlaceLibrary by akexorcist.
the class GoogleDirection method animateDirection.
public void animateDirection(GoogleMap gm, ArrayList<LatLng> direction, int speed, boolean cameraLock, boolean isCameraTilt, boolean isCameraZoom, boolean drawMarker, MarkerOptions mo, boolean flatMarker, boolean drawLine, PolylineOptions po) {
if (direction.size() > 1) {
isAnimated = true;
animatePositionList = direction;
animateSpeed = speed;
this.drawMarker = drawMarker;
this.drawLine = drawLine;
this.flatMarker = flatMarker;
this.isCameraTilt = isCameraTilt;
this.isCameraZoom = isCameraZoom;
step = 0;
this.cameraLock = cameraLock;
this.gm = gm;
setCameraUpdateSpeed(speed);
beginPosition = animatePositionList.get(step);
endPosition = animatePositionList.get(step + 1);
animateMarkerPosition = beginPosition;
if (mAnimateListener != null)
mAnimateListener.onProgress(step, animatePositionList.size());
if (cameraLock) {
float bearing = getBearing(beginPosition, endPosition);
CameraPosition.Builder cameraBuilder = new CameraPosition.Builder().target(animateMarkerPosition).bearing(bearing);
if (isCameraTilt)
cameraBuilder.tilt(90);
else
cameraBuilder.tilt(gm.getCameraPosition().tilt);
if (isCameraZoom)
cameraBuilder.zoom(zoom);
else
cameraBuilder.zoom(gm.getCameraPosition().zoom);
CameraPosition cameraPosition = cameraBuilder.build();
gm.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
}
if (drawMarker) {
if (mo != null)
animateMarker = gm.addMarker(mo.position(beginPosition));
else
animateMarker = gm.addMarker(new MarkerOptions().position(beginPosition));
if (flatMarker) {
animateMarker.setFlat(true);
float rotation = getBearing(animateMarkerPosition, endPosition) + 180;
animateMarker.setRotation(rotation);
}
}
if (drawLine) {
if (po != null)
animateLine = gm.addPolyline(po.add(beginPosition).add(beginPosition).add(endPosition).width(dpToPx((int) po.getWidth())));
else
animateLine = gm.addPolyline(new PolylineOptions().width(dpToPx(5)));
}
new Handler().postDelayed(r, speed);
if (mAnimateListener != null)
mAnimateListener.onStart();
}
}
Aggregations