نشان دادن یک شهر

پرسیده شده
فعالیت 901 روز پیش
دیده شده 494 بار
0

سلام 

تو پروژم میخوام فقط لوکیشن یک شهر رو بگیره ممنون میشم مشکل کد رو بگید

 

if (cityName.equals("tehran")) {
                                        origin = Point.fromLngLat(mapTargetLatLng.getLongitude(), mapTargetLatLng.getLatitude());
                                        originTitle = address;

                                        if (origin != null && originTitle != null) {
                                             //getRoute(mapboxMap,origin,destination);
                                             //loadedStyle.addLayer(routeLayer);

                                            Bundle bundle = new Bundle();

                                            bundle.putString(EXTRA_KEY_ORIGIN_LAT, String.valueOf(origin.latitude()));
                                            bundle.putString(EXTRA_KEY_ORIGIN_LON, String.valueOf(origin.longitude()));
                                            bundle.putString(EXTRA_KEY_ORIGIN_TITLE, originTitle);

                                            Intent intent = new Intent(PostalActivity.this, PostalShippingActivity.class);
                                            intent.putExtra(EXTRA_KEY_DATA, bundle);
                                            startActivity(intent);
                                        } else {
                                            Toast.makeText(PostalActivity.this, "لطفا مبدا را انتخاب کنید", Toast.LENGTH_SHORT).show();
                                        }
                                        // Hide the hovering red hovering ImageView marker
                                        originMarker.setVisibility(View.INVISIBLE);

                                        // Transform the appearance of the button to become the cancel button
                                        selectOriginLocationButton.setText(getString(R.string.remove_origin));


                                        // Show the SymbolLayer icon to represent the selected map location
                                        if (style.getLayer(DROPPED_MARKER_LAYER_ID) != null) {
                                            GeoJsonSource source = style.getSourceAs("dropped-marker-source-id");
                                            if (source != null) {
                                                source.setGeoJson(Point.fromLngLat(mapTargetLatLng.getLongitude(), mapTargetLatLng.getLatitude()));
                                            }
                                            droppedOriginMarkerLayer = style.getLayer(DROPPED_MARKER_LAYER_ID);
                                            if (droppedOriginMarkerLayer != null) {
                                                droppedOriginMarkerLayer.setProperties(visibility(VISIBLE));
                                            }
                                        }

                                    } else {
                                        Toast.makeText(PostalActivity.this, getString(R.string.city_not_available), Toast.LENGTH_SHORT).show();

                                    }

 

در قسمت if  شهر تهران رو میخوام بگیره وقتی  if رو بردارم کد درست کار میکنه ولی زمانی که if هستش چ با فارس یا انگلیسی تایپ کنم قسمت if اجرا نمیشه و else if  اجرا میشه

فایل پیوست

محمد لطفی
محمد لطفی

9 آبان 00

0
حذف شده

سلام محمد جان وقت بخیر

 

متاسفانه گوگل ما رو تحریم کرده و بهتره اگر پروزه ای دارید از سرویس های ایرانی نظیر نشان یا map.ir استفاده کنید .

حتی سرویس های ایرانی نظیر اسنپ , الو پیک , بیمه , و غیره هم از سرویس های ایرانی استفاده میکنند که بیس همگی open street map هست

هر دو سرویس داکیومنتیشن های خوبی ارایه دادند که میتونید استفاده کنید.

فایل پیوست

پوریا شفیعی

توسط

پوریا شفیعی

9 آبان 00

حذف شده
سلام من مشکل رو با یه if تودرتو درست کردم مثلا سنندج رو گرفتم ولی اگه بخوام شهرهای دیگه هم اضافه کنم سخت میشه
محمد لطفی

10 آبان 00

0
حذف شده
if (origin.latitude() > 35.23 & origin.longitude() < 47.1 ){
                                    if (origin.latitude() < 35.35 & origin.longitude() > 46.95) {
فایل پیوست

محمد لطفی

توسط

محمد لطفی

10 آبان 00

0
حذف شده

سلام مجدد محمد جان من خودم بخاطر شرایط تحریم از این سرویس استفاده نمیکنم اما براتون سرچی زدم و این نتایج بدست اوردم :

لینک  (آموزش ویدیویی) 

لینک دایکومنتیشن

فایل پیوست

پوریا شفیعی

توسط

پوریا شفیعی

10 آبان 00

0
حذف شده

سلام اقای شفیعی 

از Open map Street هم استفاده کردم ولی نشون نمیده

public class MapApiService {
    private static Retrofit retrofit=null;

    public static Retrofit getRetrofit() {

        Gson gson = new GsonBuilder()
                .setLenient()
                .create();

        if (retrofit == null) {
            retrofit = new Retrofit.Builder()
                    .baseUrl("https://nominatim.openstreetmap.org")
                    .addConverterFactory(GsonConverterFactory.create(gson))
                    .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                    .build();
        }
        return retrofit;
    }
}

 

فایل پیوست

محمد لطفی

توسط

محمد لطفی

13 آبان 00

حذف شده
در بالا براتون دو تا لینک ارسال کردم طبق اون برید مشکلتون حل میشه
پوریا شفیعی

13 آبان 00