লোকেশন ডেটা

মোবাইল অ্যাপ্লিকেশনের অনন্য ফিচারগুলির মধ্যে একটি হল লোকেশন সচেতনতা। মোবাইল ব্যবহারকারীরা তাদের ডিভাইস সব জায়গায় নিয়ে যান এবং আপনার অ্যাপে লোকেশন অ্যাওয়ারনেস যোগ করলে ব্যবহারকারীরা আরও প্রাসঙ্গিক অভিজ্ঞতা পান।

কোডের নমুনা

GitHub-এ ApiDemos রিপোজিটরি-তে এমন নমুনা আছে যা ম্যাপে লোকেশন ব্যবহারের ডেমো দেয়:

Kotlin

Java

লোকেশন ডেটা নিয়ে কাজ করা

Android ডিভাইসে উপলভ্য লোকেশন ডেটার মধ্যে ডিভাইসের বর্তমান লোকেশন — বিভিন্ন প্রযুক্তির সমন্বয়ে পিনপয়েন্ট করা — দিক ও মুভমেন্টের পদ্ধতি এবং ডিভাইসটি আগে থেকে নির্ধারিত ভৌগোলিক সীমানা বা জিওফেন্সের বাইরে গেছে কিনা তা অন্তর্ভুক্ত থাকে। আপনার অ্যাপ্লিকেশনের প্রয়োজনীয়তার উপর নির্ভর করে, লোকেশন ডেটা নিয়ে কাজ করার জন্য আপনি বিভিন্ন উপায়ের মধ্যে থেকে বেছে নিতে পারেন:

  • আমার লোকেশন লেয়ার ম্যাপে ডিভাইসের লোকেশন দেখানোর একটি সহজ উপায় প্রদান করে। এটি কোনও ডেটা প্রদান করে না।
  • লোকেশন ডেটার জন্য সব প্রোগ্রাম্যাটিক অনুরোধের ক্ষেত্রে Google Play পরিষেবা লোকেশন API ব্যবহার করার সাজেশন দেওয়া হয়।
  • LocationSource ইন্টারফেস আপনাকে কাস্টম লোকেশন প্রোভাইডার প্রদান করার অনুমতি দেয়।

লোকেশন অ্যাক্সেস করার অনুমতি

আপনার অ্যাপকে ব্যবহারকারীর লোকেশন অ্যাক্সেস করতে হলে, আপনাকে অবশ্যই আপনার অ্যাপে প্রাসঙ্গিক Android লোকেশন সংক্রান্ত অনুমতি যোগ করে অনুমতি চেয়ে নিতে হবে।

Android দুটি লোকেশন সংক্রান্ত অনুমতি দেয়: ACCESS_COARSE_LOCATION এবং ACCESS_FINE_LOCATION। আপনার বেছে নেওয়া অনুমতি API-এর মাধ্যমে পাওয়া লোকেশন ডেটার নির্ভুলতা নির্ধারণ করে।

  • android.permission.ACCESS_COARSE_LOCATION – API-কে ডিভাইসের আনুমানিক লোকেশন দেখানোর অনুমতি দেয়। এই অনুমতি লোকেশন পরিষেবা থেকে ডিভাইসের আনুমানিক লোকেশন প্রদান করে, যেমনটি আনুমানিক লোকেশন অ্যাকুরেসি সংক্রান্ত ডকুমেন্টেশনে বর্ণনা করা হয়েছে।
  • android.permission.ACCESS_FINE_LOCATION – API-কে উপলভ্য লোকেশন প্রদানকারী থেকে যতটা সম্ভব সুনির্দিষ্ট লোকেশন নির্ধারণ করতে দেয়, এর মধ্যে গ্লোবাল পজিশনিং সিস্টেম (জিপিএস) সহ ওয়াই-ফাই ও মোবাইল সেল ডেটা অন্তর্ভুক্ত।

অ্যাপ ম্যানিফেস্টে অনুমতি যোগ করুন

আপনার অ্যাপের কাজ করার জন্য যদি শুধুমাত্র আনুমানিক লোকেশন প্রয়োজন হয়, তাহলে আপনার অ্যাপের ম্যানিফেস্ট ফাইলে ACCESS_COARSE_LOCATION অনুমতি যোগ করুন:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myapp" >
  ...
  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
  ...
</manifest>

তবে, সুনির্দিষ্ট লোকেশন প্রয়োজন হলে, আপনার অ্যাপের মেনিফেস্ট ফাইলে ACCESS_COARSE_LOCATION এবং ACCESS_FINE_LOCATION, দুটি অনুমতিই যোগ করুন:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myapp" >
  ...
  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
  ...
</manifest>

রানটাইম অনুমতির জন্য অনুরোধ করা

Android 6.0 (Marshmallow) অনুমতি ম্যানেজ করার জন্য একটি নতুন মডেল নিয়ে এসেছে, যা ব্যবহারকারীরা অ্যাপ ইনস্টল ও আপগ্রেড করার সময় প্রসেসকে আরও সহজ করে তোলে। আপনার অ্যাপ API লেভেল ২৩ বা তার পরের ভার্সনকে টার্গেট করলে, আপনি নতুন অনুমতি মডেল ব্যবহার করতে পারবেন।

আপনার অ্যাপ নতুন পারমিশন মডেল সমর্থন করলে এবং ডিভাইসে Android 6.0 (Marshmallow) বা তার পরবর্তী ভার্সন থাকলে, অ্যাপ ইনস্টল বা আপগ্রেড করার সময় ব্যবহারকারীকে কোনও পারমিশন দিতে হয় না। রানটাইমে প্রয়োজনীয় পারমিশন আছে কিনা তা অ্যাপকে চেক করে দেখতে হয় এবং না থাকলে পারমিশনের জন্য অনুরোধ করতে হয়। সিস্টেম ব্যবহারকারীকে অনুমতি চেয়ে একটি ডায়ালগ দেখায়।

ব্যবহারকারীর সেরা অভিজ্ঞতার জন্য, প্রাসঙ্গিকতার ভিত্তিতে অনুমতির অনুরোধ করা গুরুত্বপূর্ণ। আপনার অ্যাপের কার্যকারিতার জন্য লোকেশন অপরিহার্য হলে, অ্যাপ স্টার্টআপে লোকেশন সংক্রান্ত অনুমতির জন্য অনুরোধ করা উচিত। এটি করার একটি ভাল উপায় হল, একটি আন্তরিক স্বাগত স্ক্রিন বা উইজার্ডের মাধ্যমে ব্যবহারকারীদের জানানো যে কেন অনুমতি প্রয়োজন।

অ্যাপের কার্যকারিতার শুধুমাত্র কোনও অংশের জন্য যদি অনুমতির প্রয়োজন হয়, তাহলে অ্যাপটি যখন সেই অ্যাকশন পারফর্ম করবে, তখন আপনার লোকেশন সংক্রান্ত অনুমতি চাওয়ার অনুরোধ করা উচিত।

ব্যবহারকারী অনুমতি না দিলে, অ্যাপটিকে অবশ্যই সেই পরিস্থিতি সাবলীলভাবে ম্যানেজ করতে হবে। যেমন, কোনও নির্দিষ্ট ফিচারের জন্য অনুমতি প্রয়োজন হলে, অ্যাপটি সেই ফিচার বন্ধ করে দিতে পারে। অ্যাপের কার্যকারিতার জন্য অনুমতিটি অপরিহার্য হলে, অ্যাপটি তার সমস্ত কার্যকারিতা বন্ধ করে দিতে পারে এবং ব্যবহারকারীকে জানাতে পারে যে তাদের অনুমতি দিতে হবে।

নিম্নলিখিত কোড স্যাম্পেল AndroidX লাইব্রেরি ব্যবহার করে অনুমতি চেক করে 'আমার লোকেশন' লেয়ার চালু করার আগে। তারপরে, এটি সাপোর্ট লাইব্রেরি থেকে ActivityCompat.OnRequestPermissionsResultCallback ইমপ্লিমেন্ট করে অনুমতির অনুরোধের ফলাফল হ্যান্ডেল করে:

Kotlin

// Copyright 2026 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.example.kotlindemos

import com.example.common_ui.catalog.Sample
import com.example.common_ui.catalog.Complexity
import com.example.common_ui.catalog.Framework

import android.Manifest
import android.annotation.SuppressLint
import android.content.pm.PackageManager
import android.location.Location
import android.os.Bundle
import android.view.View
import android.widget.Toast

import androidx.core.app.ActivityCompat
import androidx.core.app.ActivityCompat.OnRequestPermissionsResultCallback
import androidx.core.content.ContextCompat
import com.example.common_ui.R
import com.example.kotlindemos.PermissionUtils.PermissionDeniedDialog.Companion.newInstance
import com.example.kotlindemos.PermissionUtils.isPermissionGranted
import com.google.android.gms.maps.GoogleMap
import com.google.android.gms.maps.GoogleMap.OnMyLocationButtonClickListener
import com.google.android.gms.maps.GoogleMap.OnMyLocationClickListener
import com.google.android.gms.maps.OnMapReadyCallback
import com.google.android.gms.maps.SupportMapFragment

/**
 * This demo shows how GMS Location can be used to check for changes to the users location.  The
 * "My Location" button uses GMS Location to set the blue dot representing the users location.
 * Permission for [Manifest.permission.ACCESS_FINE_LOCATION] and [Manifest.permission.ACCESS_COARSE_LOCATION]
 * are requested at run time. If either permission is not granted, the Activity is finished with an error message.
 */
@Sample(
    id = "com.example.kotlindemos.MyLocationDemoActivity",
    title = "My Location Layer",
    description = "Enabling blue dot location indicator and My Location button with runtime permissions.",
    category = "Location & Sensors",
    complexity = Complexity.SIMPLE,
    tags = ["#location", "#mylocation", "#permissions", "#bluedot"],
    purpose = "Demonstrates requesting ACCESS_FINE_LOCATION permissions and enabling the blue dot location layer.",
    successCriteria = "Tapping My Location button centers camera on user's current GPS position.",
    failureIndicators = "Permission denial causes unhandled crash or location button missing.",
    framework = Framework.KOTLIN_VIEWS
)
class MyLocationDemoActivity : SamplesBaseActivity(),
    OnMyLocationButtonClickListener,
    OnMyLocationClickListener, OnMapReadyCallback,
    OnRequestPermissionsResultCallback {
    /**
     * Flag indicating whether a requested permission has been denied after returning in
     * [.onRequestPermissionsResult].
     */
    private var permissionDenied = false
    private lateinit var map: GoogleMap
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.my_location_demo)
        val mapFragment =
            supportFragmentManager.findFragmentById(R.id.map) as SupportMapFragment?
        mapFragment?.getMapAsync(this)
        applyInsets(findViewById(R.id.map_container))
    }

    override fun onMapReady(googleMap: GoogleMap) {
        map = googleMap
        googleMap.setOnMyLocationButtonClickListener(this)
        googleMap.setOnMyLocationClickListener(this)
        enableMyLocation()
    }

    /**
     * Enables the My Location layer if the fine location permission has been granted.
     */
    @SuppressLint("MissingPermission")
    private fun enableMyLocation() {

        // 1. Check if permissions are granted, if so, enable the my location layer
        if (ContextCompat.checkSelfPermission(
                this,
                Manifest.permission.ACCESS_FINE_LOCATION
            ) == PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(
                this,
                Manifest.permission.ACCESS_COARSE_LOCATION
            ) == PackageManager.PERMISSION_GRANTED
        ) {
            map.isMyLocationEnabled = true
            return
        }

        // 2. If if a permission rationale dialog should be shown
        if (ActivityCompat.shouldShowRequestPermissionRationale(
                this,
                Manifest.permission.ACCESS_FINE_LOCATION
            ) || ActivityCompat.shouldShowRequestPermissionRationale(
                this,
                Manifest.permission.ACCESS_COARSE_LOCATION
            )
        ) {
            PermissionUtils.RationaleDialog.newInstance(
                LOCATION_PERMISSION_REQUEST_CODE, true
            ).show(supportFragmentManager, "dialog")
            return
        }

        // 3. Otherwise, request permission
        ActivityCompat.requestPermissions(
            this,
            arrayOf(
                Manifest.permission.ACCESS_FINE_LOCATION,
                Manifest.permission.ACCESS_COARSE_LOCATION
            ),
            LOCATION_PERMISSION_REQUEST_CODE
        )
    }

    override fun onMyLocationButtonClick(): Boolean {
        Toast.makeText(this, "MyLocation button clicked", Toast.LENGTH_SHORT)
            .show()
        // Return false so that we don't consume the event and the default behavior still occurs
        // (the camera animates to the user's current position).
        return false
    }

    override fun onMyLocationClick(location: Location) {
        Toast.makeText(this, "Current location:\n$location", Toast.LENGTH_LONG)
            .show()
    }

    override fun onRequestPermissionsResult(
        requestCode: Int,
        permissions: Array<String>,
        grantResults: IntArray
    ) {
        if (requestCode != LOCATION_PERMISSION_REQUEST_CODE) {
            super.onRequestPermissionsResult(
                requestCode,
                permissions,
                grantResults
            )
            return
        }

        if (isPermissionGranted(
                permissions,
                grantResults,
                Manifest.permission.ACCESS_FINE_LOCATION
            ) || isPermissionGranted(
                permissions,
                grantResults,
                Manifest.permission.ACCESS_COARSE_LOCATION
            )
        ) {
            // Enable the my location layer if the permission has been granted.
            enableMyLocation()
        } else {
            // Permission was denied. Display an error message
            // Display the missing permission error dialog when the fragments resume.
            permissionDenied = true
        }
    }

    override fun onResumeFragments() {
        super.onResumeFragments()
        if (permissionDenied) {
            // Permission was not granted, display error dialog.
            showMissingPermissionError()
            permissionDenied = false
        }
    }

    /**
     * Displays a dialog with error message explaining that the location permission is missing.
     */
    private fun showMissingPermissionError() {
        newInstance(true).show(supportFragmentManager, "dialog")
    }

    companion object {
        /**
         * Request code for location permission request.
         *
         * @see .onRequestPermissionsResult
         */
        private const val LOCATION_PERMISSION_REQUEST_CODE = 1
    }
}

Java

// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.


package com.example.mapdemo;

import com.example.common_ui.catalog.Sample;
import com.example.common_ui.catalog.Complexity;
import com.example.common_ui.catalog.Framework;

import android.Manifest.permission;
import android.annotation.SuppressLint;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.GoogleMap.OnMyLocationButtonClickListener;
import com.google.android.gms.maps.GoogleMap.OnMyLocationClickListener;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;

import android.Manifest;
import android.content.pm.PackageManager;
import android.location.Location;
import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import android.widget.Toast;

/**
 * This demo shows how GMS Location can be used to check for changes to the users location.  The "My
 * Location" button uses GMS Location to set the blue dot representing the users location.
 * Permission for {@link android.Manifest.permission#ACCESS_FINE_LOCATION} and {@link
 * android.Manifest.permission#ACCESS_COARSE_LOCATION} are requested at run time. If either
 * permission is not granted, the Activity is finished with an error message.
 */
@Sample(
    id = "my_location",
    title = "My Location Layer",
    description = "Enabling blue dot location indicator and My Location button with runtime permissions.",
    category = "Location & Sensors",
    complexity = Complexity.SIMPLE,
    tags = {"#location", "#mylocation", "#permissions", "#bluedot"},
    purpose = "Demonstrates requesting ACCESS_FINE_LOCATION permissions and enabling the blue dot location layer.",
    successCriteria = "Tapping My Location button centers camera on user's current GPS position.",
    failureIndicators = "Permission denial causes unhandled crash or location button missing.",
    framework = Framework.JAVA_VIEWS
)
public class MyLocationDemoActivity extends SamplesBaseActivity
    implements
    OnMyLocationButtonClickListener,
    OnMyLocationClickListener,
    OnMapReadyCallback,
    ActivityCompat.OnRequestPermissionsResultCallback {

    /**
     * Request code for location permission request.
     *
     * @see #onRequestPermissionsResult(int, String[], int[])
     */
    private static final int LOCATION_PERMISSION_REQUEST_CODE = 1;

    /**
     * Flag indicating whether a requested permission has been denied after returning in {@link
     * #onRequestPermissionsResult(int, String[], int[])}.
     */
    private boolean permissionDenied = false;

    private GoogleMap map;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(com.example.common_ui.R.layout.my_location_demo);

        SupportMapFragment mapFragment =
            (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
        mapFragment.getMapAsync(this);
        applyInsets(findViewById(com.example.common_ui.R.id.map_container));
    }

    @Override
    public void onMapReady(@NonNull GoogleMap googleMap) {
        map = googleMap;
        map.setOnMyLocationButtonClickListener(this);
        map.setOnMyLocationClickListener(this);
        enableMyLocation();
    }

    /**
     * Enables the My Location layer if the fine location permission has been granted.
     */
    @SuppressLint("MissingPermission")
    private void enableMyLocation() {
        // 1. Check if permissions are granted, if so, enable the my location layer
        if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
            == PackageManager.PERMISSION_GRANTED
            || ContextCompat.checkSelfPermission(this, permission.ACCESS_COARSE_LOCATION)
            == PackageManager.PERMISSION_GRANTED) {
            map.setMyLocationEnabled(true);
            return;
        }

        // 2. Otherwise, request location permissions from the user.
        PermissionUtils.requestLocationPermissions(this, LOCATION_PERMISSION_REQUEST_CODE, true);
    }

    @Override
    public boolean onMyLocationButtonClick() {
        Toast.makeText(this, "MyLocation button clicked", Toast.LENGTH_SHORT).show();
        // Return false so that we don't consume the event and the default behavior still occurs
        // (the camera animates to the user's current position).
        return false;
    }

    @Override
    public void onMyLocationClick(@NonNull Location location) {
        Toast.makeText(this, "Current location:\n" + location, Toast.LENGTH_LONG).show();
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
        @NonNull int[] grantResults) {
        if (requestCode != LOCATION_PERMISSION_REQUEST_CODE) {
            super.onRequestPermissionsResult(requestCode, permissions, grantResults);
            return;
        }

        if (PermissionUtils.isPermissionGranted(permissions, grantResults,
            Manifest.permission.ACCESS_FINE_LOCATION) || PermissionUtils
            .isPermissionGranted(permissions, grantResults,
                Manifest.permission.ACCESS_COARSE_LOCATION)) {
            // Enable the my location layer if the permission has been granted.
            enableMyLocation();
        } else {
            // Permission was denied. Display an error message
            // Display the missing permission error dialog when the fragments resume.
            permissionDenied = true;
        }
    }

    @Override
    protected void onResumeFragments() {
        super.onResumeFragments();
        if (permissionDenied) {
            // Permission was not granted, display error dialog.
            showMissingPermissionError();
            permissionDenied = false;
        }
    }

    /**
     * Displays a dialog with error message explaining that the location permission is missing.
     */
    private void showMissingPermissionError() {
        PermissionUtils.PermissionDeniedDialog
            .newInstance(true).show(getSupportFragmentManager(), "dialog");
    }

}

আমার লোকেশন লেয়ার

ম্যাপে ব্যবহারকারীর বর্তমান অবস্থান দেখানোর জন্য আপনি 'আমার লোকেশন' লেয়ার এবং 'আমার লোকেশন' বোতাম ব্যবহার করতে পারেন। ম্যাপে 'আমার লোকেশন' লেয়ার চালু করতে mMap.setMyLocationEnabled() কল করুন।

নিচের নমুনাটি 'আমার লোকেশন' লেয়ারের একটি সাধারণ ব্যবহার দেখায়:

Kotlin

// TODO: Before enabling the My Location layer, you must request
// location permission from the user. This sample does not include
// a request for location permission.
map.setMyLocationEnabled(true)
map.setOnMyLocationButtonClickListener {
    Toast.makeText(context, "MyLocation button clicked", Toast.LENGTH_SHORT).show()
    // Return false so that we don't consume the event and the default behavior still occurs
    // (the camera animates to the user's current position).
    false
}
map.setOnMyLocationClickListener { location ->
    Toast.makeText(context, "Current location:\n$location", Toast.LENGTH_LONG).show()
}

      

Java

// TODO: Before enabling the My Location layer, you must request
// location permission from the user. This sample does not include
// a request for location permission.
map.setMyLocationEnabled(true);
map.setOnMyLocationButtonClickListener(new GoogleMap.OnMyLocationButtonClickListener() {
    @Override
    public boolean onMyLocationButtonClick() {
        Toast.makeText(context, "MyLocation button clicked", Toast.LENGTH_SHORT).show();
        // Return false so that we don't consume the event and the default behavior still occurs
        // (the camera animates to the user's current position).
        return false;
    }
});
map.setOnMyLocationClickListener(new GoogleMap.OnMyLocationClickListener() {
    @Override
    public void onMyLocationClick(@NonNull Location location) {
        Toast.makeText(context, "Current location:\n" + location, Toast.LENGTH_LONG).show();
    }
});

      

'আমার লোকেশন' লেয়ার চালু করা থাকলে, 'আমার লোকেশন' বোতামটি ম্যাপের উপরের ডানদিকের কোণে দেখা যায়। ব্যবহারকারী বোতামে ক্লিক করলে, ক্যামেরা ডিভাইসের বর্তমান লোকেশনে ম্যাপটি কেন্দ্র করে, যদি এটি জানা থাকে। ডিভাইস স্থির থাকলে ম্যাপে একটি ছোট নীল বিন্দু দিয়ে লোকেশন বোঝানো হয় অথবা ডিভাইসটি চলতে থাকলে শেভরন চিহ্ন দিয়ে বোঝানো হয়।

নিচের স্ক্রিনশটে উপরে ডানদিকে 'আমার লোকেশন' বোতাম এবং ম্যাপের কেন্দ্রে 'আমার লোকেশন' নীল বিন্দু দেখানো হয়েছে:

UiSettings.setMyLocationButtonEnabled(false) কল করে আপনি 'আমার লোকেশন' বোতামটি দেখানো বন্ধ করতে পারেন।

আপনার অ্যাপ নিম্নলিখিত ইভেন্টে প্রতিক্রিয়া জানাতে পারে:

  • ব্যবহারকারী 'আমার লোকেশন' বোতামে ক্লিক করলে, আপনার অ্যাপ GoogleMap.OnMyLocationButtonClickListener থেকে একটি onMyLocationButtonClick() কলব্যাক পায়।
  • ব্যবহারকারী 'আমার লোকেশন' নীল বিন্দুতে ক্লিক করলে, আপনার অ্যাপ onMyLocationClick() থেকে GoogleMap.OnMyLocationClickListener একটি কলব্যাক পায়।

Google Play পরিষেবার লোকেশন API

Google Play পরিষেবার লোকেশন API হল আপনার Android অ্যাপ্লিকেশনে লোকেশন সংক্রান্ত তথ্য যোগ করার সবচেয়ে ভালো পদ্ধতি। এতে এমন কার্যকারিতা অন্তর্ভুক্ত রয়েছে যা আপনাকে এগুলি করতে দেয়:

  • ডিভাইসের লোকেশন নির্ধারণ করা।
  • লোকেশন পরিবর্তনের জন্য অপেক্ষা করুন।
  • ডিভাইসটি মুভ করলে, পরিবহনের মোড নির্ধারণ করুন।
  • জিওফেন্স নামে পরিচিত আগে থেকে নির্দিষ্ট করা ভৌগোলিক অঞ্চল তৈরি ও মনিটর করা।

লোকেশন API-এর সাহায্যে আপনি সহজেই ব্যাটারি সাশ্রয়কারী, লোকেশন-সচেতন অ্যাপ্লিকেশন তৈরি করতে পারবেন। Android-এর জন্য Maps SDK-এর মতো, লোকেশন API, Google Play পরিষেবা SDK-এর অংশ হিসেবে ডিস্ট্রিবিউট করা হয়। Location API সম্পর্কে আরও তথ্য পেতে, Android ট্রেনিং ক্লাস আপনার অ্যাপকে লোকেশন সচেতন করে তোলা অথবা Location API রেফারেন্স দেখুন। Google Play পরিষেবা SDK-এর অংশ হিসেবে কোডের উদাহরণ অন্তর্ভুক্ত করা হয়েছে।