omidmo

توسعه دهنده اندروید
  • تعداد ارسال ها

    2
  • تاریخ عضویت

  • آخرین بازدید

اعتبار در انجمن

0 Neutral

درباره omidmo

  • درجه
    Newbie
  1. سلام و عرض ادب من 2 روزه دارم روی یه سورس کار میکنم خوشبختانه ارور هاشو گرفتمو تونستم رانش کن اما جواب درستی به من نمیده واقعا دیگه خسته شدم موضوع وصل کردن 2 نقطه در گوگل مپ direction من API Key رو ساختم و تو مانیفست گذاشتم ترو خدا یه نگاهی بهش بندازید لینک سورس رو اصلی رو براتون میزارم https://github.com/akexorcist/Android-GoogleDirectionLibrary [align=left]import android.graphics.Color;[/align] [align=left]import android.os.Bundle;[/align] [align=left]import android.support.design.widget.Snackbar;[/align] [align=left]import android.support.v7.app.AppCompatActivity;[/align] [align=left]import android.view.View;[/align] [align=left]import android.widget.Button;[/align] [align=left]import com.akexorcist.googledirection.DirectionCallback;[/align] [align=left]import com.akexorcist.googledirection.GoogleDirection;[/align] [align=left]import com.akexorcist.googledirection.constant.TransportMode;[/align] [align=left]import com.akexorcist.googledirection.model.Direction;[/align] [align=left]import com.akexorcist.googledirection.util.DirectionConverter;[/align] [align=left]import com.google.android.gms.maps.CameraUpdateFactory;[/align] [align=left]import com.google.android.gms.maps.GoogleMap;[/align] [align=left]import com.google.android.gms.maps.OnMapReadyCallback;[/align] [align=left]import com.google.android.gms.maps.SupportMapFragment;[/align] [align=left]import com.google.android.gms.maps.model.LatLng;[/align] [align=left]import com.google.android.gms.maps.model.MarkerOptions;[/align] [align=left]import java.util.ArrayList;[/align] [align=left]public class SimpleDirectionActivity extends AppCompatActivity implements OnMapReadyCallback, View.OnClickListener, DirectionCallback {[/align] [align=left] private Button btnRequestDirection;[/align] [align=left] private GoogleMap googleMap;[/align] [align=left] private String serverKey = "AIzaSyDdlocE8J6qf2j_bf3AKrjSkpDCATALx4k";[/align] [align=left] private LatLng camera = new LatLng(37.782437, -122.4281893);[/align] [align=left] private LatLng origin = new LatLng(37.7849569, -122.4068855);[/align] [align=left] private LatLng destination = new LatLng(37.7814432, -122.4460177);[/align] [align=left] @Override[/align] [align=left] protected void onCreate(Bundle savedInstanceState) {[/align] [align=left] super.onCreate(savedInstanceState);[/align] [align=left] setContentView(R.layout.activity_simple_direction);[/align] [align=left] btnRequestDirection = (Button) findViewById(R.id.btn_request_direction);[/align] [align=left] btnRequestDirection.setOnClickListener(this);[/align] [align=left] ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMapAsync(this);[/align] [align=left] }[/align] [align=left] @Override[/align] [align=left] public void onMapReady(GoogleMap googleMap) {[/align] [align=left] this.googleMap = googleMap;[/align] [align=left] googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(camera, 13));[/align] [align=left] }[/align] [align=left] @Override[/align] [align=left] public void onClick(View v) {[/align] [align=left] int id = v.getId();[/align] [align=left] if (id == R.id.btn_request_direction) {[/align] [align=left] requestDirection();[/align] [align=left] }[/align] [align=left] }[/align] [align=left] public void requestDirection() {[/align] [align=left] Snackbar.make(btnRequestDirection, "Direction Requesting...", Snackbar.LENGTH_SHORT).show();[/align] [align=left] GoogleDirection.withServerKey(serverKey)[/align] [align=left] .from(origin)[/align] [align=left] .to(destination)[/align] [align=left] .transportMode(TransportMode.DRIVING)[/align] [align=left] .execute(this);[/align] [align=left] }[/align] [align=left] @Override[/align] [align=left] public void onDirectionSuccess(Direction direction, String rawBody) {[/align] [align=left] Snackbar.make(btnRequestDirection, "Success with status : " + direction.getStatus(), Snackbar.LENGTH_SHORT).show();[/align] [align=left] if (direction.isOK()) {[/align] [align=left] googleMap.addMarker(new MarkerOptions().position(origin));[/align] [align=left] googleMap.addMarker(new MarkerOptions().position(destination));[/align] [align=left] ArrayList directionPositionList = direction.getRouteList().get(0).getLegList().get(0).getDirectionPoint();[/align] [align=left] googleMap.addPolyline(DirectionConverter.createPolyline(this, directionPositionList, 5, Color.RED));[/align] [align=left] btnRequestDirection.setVisibility(View.GONE);[/align] [align=left] }[/align] [align=left] }[/align] [align=left] @Override[/align] [align=left] public void onDirectionFailure(Throwable t) {[/align] [align=left] Snackbar.make(btnRequestDirection, t.getMessage(), Snackbar.LENGTH_SHORT).show();[/align] [align=left] }[/align] [align=left]}[/align]
  2. اون خط junit junit رو کامل پاک کن ماله اونم هست جاوا تونم نصب کنید و از منوی project structure آدرس JDK رو بدید