ঘটনা

প্ল্যাটফর্ম নির্বাচন করুন: অ্যান্ড্রয়েড আইওএস জাভাস্ক্রিপ্ট

Android এর জন্য Maps SDK ব্যবহার করে, আপনি মানচিত্রে ইভেন্ট শুনতে পারেন।

কোড নমুনা

GitHub-এ ApiDemos সংগ্রহস্থলে এমন নমুনা রয়েছে যা ইভেন্ট এবং শ্রোতাদের প্রদর্শন করে:

কোটলিন

জাভা

ম্যাপ ক্লিক / দীর্ঘ ক্লিক ইভেন্ট

আপনি যদি মানচিত্রের একটি বিন্দুতে ট্যাপ করা ব্যবহারকারীর প্রতিক্রিয়া জানাতে চান, আপনি একটি OnMapClickListener ব্যবহার করতে পারেন যা আপনি GoogleMap.setOnMapClickListener(OnMapClickListener) কল করে মানচিত্রে সেট করতে পারেন। যখন একজন ব্যবহারকারী মানচিত্রের কোথাও ক্লিক করেন (ট্যাপ করেন), আপনি একটি onMapClick(LatLng) ইভেন্ট পাবেন যা ব্যবহারকারীর ক্লিক করা মানচিত্রের অবস্থান নির্দেশ করে। মনে রাখবেন যে আপনার যদি স্ক্রিনে সংশ্লিষ্ট অবস্থানের প্রয়োজন হয় (পিক্সেলগুলিতে), আপনি মানচিত্র থেকে একটি Projection পেতে পারেন যা আপনাকে অক্ষাংশ/দ্রাঘিমাংশ স্থানাঙ্ক এবং স্ক্রীন পিক্সেল স্থানাঙ্কের মধ্যে রূপান্তর করতে দেয়।

আপনি একটি OnMapLongClickListener এর মাধ্যমে দীর্ঘ ক্লিক ইভেন্টগুলির জন্যও শুনতে পারেন যা আপনি GoogleMap.setOnMapLongClickListener(OnMapLongClickListener) কল করে মানচিত্রে সেট করতে পারেন৷ এই শ্রোতা ক্লিক শ্রোতার অনুরূপ আচরণ করে এবং একটি onMapLongClick(LatLng) কলব্যাকের সাথে দীর্ঘ ক্লিক ইভেন্টগুলিতে অবহিত করা হবে৷

লাইট মোডে ক্লিক ইভেন্ট অক্ষম করা হচ্ছে

লাইট মোডে ম্যাপে ক্লিক ইভেন্টগুলি অক্ষম করতে, MapView বা MapFragment ধারণ করে এমন ভিউতে setClickable() এ কল করুন। এটি দরকারী, উদাহরণস্বরূপ, একটি তালিকা দৃশ্যে একটি মানচিত্র বা মানচিত্র প্রদর্শন করার সময়, যেখানে আপনি চান যে ক্লিক ইভেন্টটি মানচিত্রের সাথে সম্পর্কিত নয় এমন একটি ক্রিয়া শুরু করতে চায়৷

ক্লিক ইভেন্টগুলি নিষ্ক্রিয় করার বিকল্পটি শুধুমাত্র লাইট মোডে উপলব্ধ৷ ক্লিক ইভেন্টগুলি অক্ষম করার ফলে চিহ্নিতকারীগুলিও অ-ক্লিকযোগ্য করে তুলবে৷ এটি মানচিত্রের অন্যান্য নিয়ন্ত্রণগুলিকে প্রভাবিত করবে না৷

একটি MapView এর জন্য:

কোটলিন



val mapView = findViewById<MapView>(R.id.mapView)
mapView.isClickable = false

      

জাভা


MapView mapView = findViewById(R.id.mapView);
mapView.setClickable(false);

      

একটি MapFragment জন্য:

কোটলিন



val mapFragment = supportFragmentManager
    .findFragmentById(R.id.map) as SupportMapFragment
val view = mapFragment.view
view?.isClickable = false

      

জাভা


SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
    .findFragmentById(R.id.map);
View view = mapFragment.getView();
view.setClickable(false);

      

ক্যামেরা পরিবর্তনের ঘটনা

মানচিত্র দৃশ্যটি একটি সমতল সমতলে নিচের দিকে তাকিয়ে থাকা ক্যামেরার মতো মডেল করা হয়েছে। আপনি ম্যাপের জুম স্তর, পোর্ট এবং দৃষ্টিকোণকে প্রভাবিত করতে ক্যামেরার বৈশিষ্ট্য পরিবর্তন করতে পারেন। ক্যামেরার গাইড দেখুন। ব্যবহারকারীরা অঙ্গভঙ্গি করে ক্যামেরাকেও প্রভাবিত করতে পারে।

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

নিম্নলিখিত নমুনা সমস্ত উপলব্ধ ক্যামেরা ইভেন্ট শ্রোতাদের চিত্রিত করে:

কোটলিন

/*
 * Copyright 2018 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
 *
 *     https://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 android.graphics.Color
import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.CompoundButton
import android.widget.SeekBar
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.google.android.gms.maps.CameraUpdate
import com.google.android.gms.maps.CameraUpdateFactory
import com.google.android.gms.maps.GoogleMap
import com.google.android.gms.maps.GoogleMap.CancelableCallback
import com.google.android.gms.maps.GoogleMap.OnCameraIdleListener
import com.google.android.gms.maps.GoogleMap.OnCameraMoveCanceledListener
import com.google.android.gms.maps.GoogleMap.OnCameraMoveListener
import com.google.android.gms.maps.GoogleMap.OnCameraMoveStartedListener
import com.google.android.gms.maps.OnMapReadyCallback
import com.google.android.gms.maps.SupportMapFragment
import com.google.android.gms.maps.model.CameraPosition
import com.google.android.gms.maps.model.LatLng
import com.google.android.gms.maps.model.PolylineOptions

/**
 * This shows how to change the camera position for the map.
 */
class CameraDemoActivity :
        AppCompatActivity(),
        OnCameraMoveStartedListener,
        OnCameraMoveListener,
        OnCameraMoveCanceledListener,
        OnCameraIdleListener,
        OnMapReadyCallback {
    /**
     * The amount by which to scroll the camera. Note that this amount is in raw pixels, not dp
     * (density-independent pixels).
     */
    private val SCROLL_BY_PX = 100
    private val TAG = CameraDemoActivity::class.java.name
    private val sydneyLatLng = LatLng(-33.87365, 151.20689)
    private val bondiLocation: CameraPosition = CameraPosition.Builder()
            .target(LatLng(-33.891614, 151.276417))
            .zoom(15.5f)
            .bearing(300f)
            .tilt(50f)
            .build()

    private val sydneyLocation: CameraPosition = CameraPosition.Builder().
            target(LatLng(-33.87365, 151.20689))
            .zoom(15.5f)
            .bearing(0f)
            .tilt(25f)
            .build()

    private lateinit var map: GoogleMap
    private lateinit var animateToggle: CompoundButton
    private lateinit var customDurationToggle: CompoundButton
    private lateinit var customDurationBar: SeekBar
    private var currPolylineOptions: PolylineOptions? = null
    private var isCanceled = false

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.camera_demo)
        animateToggle = findViewById(R.id.animate)
        customDurationToggle = findViewById(R.id.duration_toggle)
        customDurationBar = findViewById(R.id.duration_bar)

        updateEnabledState()

        val mapFragment = supportFragmentManager.findFragmentById(R.id.map) as SupportMapFragment
        mapFragment.getMapAsync(this)
    }

    override fun onResume() {
        super.onResume()
        updateEnabledState()
    }

    override fun onMapReady(googleMap: GoogleMap) {
        map = googleMap
        // return early if the map was not initialised properly
        with(googleMap) {
            setOnCameraIdleListener(this@CameraDemoActivity)
            setOnCameraMoveStartedListener(this@CameraDemoActivity)
            setOnCameraMoveListener(this@CameraDemoActivity)
            setOnCameraMoveCanceledListener(this@CameraDemoActivity)
            // We will provide our own zoom controls.
            uiSettings.isZoomControlsEnabled = false
            uiSettings.isMyLocationButtonEnabled = true

            // Show Sydney
            moveCamera(CameraUpdateFactory.newLatLngZoom(sydneyLatLng, 10f))
        }
    }

    /**
     * When the map is not ready the CameraUpdateFactory cannot be used. This should be used to wrap
     * all entry points that call methods on the Google Maps API.
     *
     * @param stuffToDo the code to be executed if the map is initialised
     */
    private fun checkReadyThen(stuffToDo: () -> Unit) {
        if (!::map.isInitialized) {
            Toast.makeText(this, R.string.map_not_ready, Toast.LENGTH_SHORT).show()
        } else {
            stuffToDo()
        }
    }

    /**
     * Called when the Go To Bondi button is clicked.
     */
    @Suppress("UNUSED_PARAMETER")
    fun onGoToBondi(view: View) {
        checkReadyThen {
            changeCamera(CameraUpdateFactory.newCameraPosition(bondiLocation))
        }
    }

    /**
     * Called when the Animate To Sydney button is clicked.
     */
    @Suppress("UNUSED_PARAMETER")
    fun onGoToSydney(view: View) {
        checkReadyThen {
            changeCamera(CameraUpdateFactory.newCameraPosition(sydneyLocation),
                    object : CancelableCallback {
                        override fun onFinish() {
                            Toast.makeText(baseContext, "Animation to Sydney complete",
                                    Toast.LENGTH_SHORT).show()
                        }

                        override fun onCancel() {
                            Toast.makeText(baseContext, "Animation to Sydney canceled",
                                    Toast.LENGTH_SHORT).show()
                        }
                    })
        }
    }

    /**
     * Called when the stop button is clicked.
     */
    @Suppress("UNUSED_PARAMETER")
    fun onStopAnimation(view: View) = checkReadyThen { map.stopAnimation() }

    /**
     * Called when the zoom in button (the one with the +) is clicked.
     */
    @Suppress("UNUSED_PARAMETER")
    fun onZoomIn(view: View) = checkReadyThen { changeCamera(CameraUpdateFactory.zoomIn()) }

    /**
     * Called when the zoom out button (the one with the -) is clicked.
     */
    @Suppress("UNUSED_PARAMETER")
    fun onZoomOut(view: View) = checkReadyThen { changeCamera(CameraUpdateFactory.zoomOut()) }

    /**
     * Called when the tilt more button (the one with the /) is clicked.
     */
    @Suppress("UNUSED_PARAMETER")
    fun onTiltMore(view: View) {
        checkReadyThen {

            val newTilt = Math.min(map.cameraPosition.tilt + 10, 90F)
            val cameraPosition = CameraPosition.Builder(map.cameraPosition).tilt(newTilt).build()

            changeCamera(CameraUpdateFactory.newCameraPosition(cameraPosition))
        }
    }

    /**
     * Called when the tilt less button (the one with the \) is clicked.
     */
    @Suppress("UNUSED_PARAMETER")
    fun onTiltLess(view: View) {
        checkReadyThen {

            val newTilt = Math.max(map.cameraPosition.tilt - 10, 0F)
            val cameraPosition = CameraPosition.Builder(map.cameraPosition).tilt(newTilt).build()

            changeCamera(CameraUpdateFactory.newCameraPosition(cameraPosition))
        }
    }

    /**
     * Called when the left arrow button is clicked. This causes the camera to move to the left
     */
    @Suppress("UNUSED_PARAMETER")
    fun onScrollLeft(view: View) {
        checkReadyThen {
            changeCamera(CameraUpdateFactory.scrollBy((-SCROLL_BY_PX).toFloat(),0f))
        }
    }

    /**
     * Called when the right arrow button is clicked. This causes the camera to move to the right.
     */
    @Suppress("UNUSED_PARAMETER")
    fun onScrollRight(view: View) {
        checkReadyThen {
            changeCamera(CameraUpdateFactory.scrollBy(SCROLL_BY_PX.toFloat(), 0f))
        }
    }

    /**
     * Called when the up arrow button is clicked. The causes the camera to move up.
     */
    @Suppress("UNUSED_PARAMETER")
    fun onScrollUp(view: View) {
        checkReadyThen {
            changeCamera(CameraUpdateFactory.scrollBy(0f, (-SCROLL_BY_PX).toFloat()))
        }
    }

    /**
     * Called when the down arrow button is clicked. This causes the camera to move down.
     */
    @Suppress("UNUSED_PARAMETER")
    fun onScrollDown(view: View) {
        checkReadyThen {
            changeCamera(CameraUpdateFactory.scrollBy(0f, SCROLL_BY_PX.toFloat()))
        }
    }

    /**
     * Called when the animate button is toggled
     */
    @Suppress("UNUSED_PARAMETER")
    fun onToggleAnimate(view: View) = updateEnabledState()

    /**
     * Called when the custom duration checkbox is toggled
     */
    @Suppress("UNUSED_PARAMETER")
    fun onToggleCustomDuration(view: View) = updateEnabledState()

    /**
     * Update the enabled state of the custom duration controls.
     */
    private fun updateEnabledState() {
        customDurationToggle.isEnabled = animateToggle.isChecked
        customDurationBar.isEnabled = animateToggle.isChecked && customDurationToggle.isChecked
    }

    /**
     * Change the camera position by moving or animating the camera depending on the state of the
     * animate toggle button.
     */
    private fun changeCamera(update: CameraUpdate, callback: CancelableCallback? = null) {
        if (animateToggle.isChecked) {
            if (customDurationToggle.isChecked) {
                // The duration must be strictly positive so we make it at least 1.
                map.animateCamera(update, Math.max(customDurationBar.progress, 1), callback)
            } else {
                map.animateCamera(update, callback)
            }
        } else {
            map.moveCamera(update)
        }
    }

    override fun onCameraMoveStarted(reason: Int) {
        if (!isCanceled) map.clear()

        var reasonText = "UNKNOWN_REASON"
        currPolylineOptions = PolylineOptions().width(5f)
        when (reason) {
            OnCameraMoveStartedListener.REASON_GESTURE -> {
                currPolylineOptions?.color(Color.BLUE)
                reasonText = "GESTURE"
            }
            OnCameraMoveStartedListener.REASON_API_ANIMATION -> {
                currPolylineOptions?.color(Color.RED)
                reasonText = "API_ANIMATION"
            }
            OnCameraMoveStartedListener.REASON_DEVELOPER_ANIMATION -> {
                currPolylineOptions?.color(Color.GREEN)
                reasonText = "DEVELOPER_ANIMATION"
            }
        }
        Log.d(TAG, "onCameraMoveStarted($reasonText)")
        addCameraTargetToPath()
    }

    /**
     * Ensures that currPolyLine options is not null before accessing it
     *
     * @param stuffToDo the code to be executed if currPolylineOptions is not null
     */
    private fun checkPolylineThen(stuffToDo: () -> Unit) {
        if (currPolylineOptions != null) stuffToDo()
    }

    override fun onCameraMove() {
        Log.d(TAG, "onCameraMove")
        // When the camera is moving, add its target to the current path we'll draw on the map.
        checkPolylineThen { addCameraTargetToPath() }
    }

    override fun onCameraMoveCanceled() {
        // When the camera stops moving, add its target to the current path, and draw it on the map.
        checkPolylineThen {
            addCameraTargetToPath()
            map.addPolyline(currPolylineOptions!!)
        }

        isCanceled = true  // Set to clear the map when dragging starts again.
        currPolylineOptions = null
        Log.d(TAG, "onCameraMoveCancelled")
    }

    override fun onCameraIdle() {
        checkPolylineThen {
            addCameraTargetToPath()
            map.addPolyline(currPolylineOptions!!)
        }

        currPolylineOptions = null
        isCanceled = false  // Set to *not* clear the map when dragging starts again.
        Log.d(TAG, "onCameraIdle")
    }
    private fun addCameraTargetToPath() {
        currPolylineOptions?.add(map.cameraPosition.target)
    }
}

জাভা

// 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 android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.SeekBar;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import com.google.android.gms.maps.CameraUpdate;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.GoogleMap.CancelableCallback;
import com.google.android.gms.maps.GoogleMap.OnCameraIdleListener;
import com.google.android.gms.maps.GoogleMap.OnCameraMoveCanceledListener;
import com.google.android.gms.maps.GoogleMap.OnCameraMoveListener;
import com.google.android.gms.maps.GoogleMap.OnCameraMoveStartedListener;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.PolylineOptions;

/**
 * This shows how to change the camera position for the map.
 */
public class CameraDemoActivity extends AppCompatActivity implements
        OnCameraMoveStartedListener,
        OnCameraMoveListener,
        OnCameraMoveCanceledListener,
        OnCameraIdleListener,
        OnMapReadyCallback {
    private static final String TAG = CameraDemoActivity.class.getName();

    /**
     * The amount by which to scroll the camera. Note that this amount is in raw pixels, not dp
     * (density-independent pixels).
     */
    private static final int SCROLL_BY_PX = 100;

    public static final CameraPosition BONDI =
            new CameraPosition.Builder().target(new LatLng(-33.891614, 151.276417))
                    .zoom(15.5f)
                    .bearing(300)
                    .tilt(50)
                    .build();

    public static final CameraPosition SYDNEY =
            new CameraPosition.Builder().target(new LatLng(-33.87365, 151.20689))
                    .zoom(15.5f)
                    .bearing(0)
                    .tilt(25)
                    .build();

    private GoogleMap map;
    private CompoundButton animateToggle;
    private CompoundButton customDurationToggle;
    private SeekBar customDurationBar;
    private PolylineOptions currPolylineOptions;
    private boolean isCanceled = false;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.camera_demo);
        animateToggle = findViewById(R.id.animate);
        customDurationToggle = findViewById(R.id.duration_toggle);
        customDurationBar = findViewById(R.id.duration_bar);

        updateEnabledState();

        SupportMapFragment mapFragment =
                (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
        mapFragment.getMapAsync(this);
    }

    @Override
    protected void onResume() {
        super.onResume();
        updateEnabledState();
    }

    @Override
    public void onMapReady(GoogleMap googleMap) {
        map = googleMap;

        map.setOnCameraIdleListener(this);
        map.setOnCameraMoveStartedListener(this);
        map.setOnCameraMoveListener(this);
        map.setOnCameraMoveCanceledListener(this);
        // We will provide our own zoom controls.
        map.getUiSettings().setZoomControlsEnabled(false);
        map.getUiSettings().setMyLocationButtonEnabled(true);

        // Show Sydney
        map.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(-33.87365, 151.20689), 10));
    }

    /**
     * When the map is not ready the CameraUpdateFactory cannot be used. This should be called on
     * all entry points that call methods on the Google Maps API.
     */
    private boolean checkReady() {
        if (map == null) {
            Toast.makeText(this, R.string.map_not_ready, Toast.LENGTH_SHORT).show();
            return false;
        }
        return true;
    }

    /**
     * Called when the Go To Bondi button is clicked.
     */
    public void onGoToBondi(View view) {
        if (!checkReady()) {
            return;
        }

        changeCamera(CameraUpdateFactory.newCameraPosition(BONDI));
    }

    /**
     * Called when the Animate To Sydney button is clicked.
     */
    public void onGoToSydney(View view) {
        if (!checkReady()) {
            return;
        }

        changeCamera(CameraUpdateFactory.newCameraPosition(SYDNEY), new CancelableCallback() {
            @Override
            public void onFinish() {
                Toast.makeText(getBaseContext(), "Animation to Sydney complete", Toast.LENGTH_SHORT)
                        .show();
            }

            @Override
            public void onCancel() {
                Toast.makeText(getBaseContext(), "Animation to Sydney canceled", Toast.LENGTH_SHORT)
                        .show();
            }
        });
    }

    /**
     * Called when the stop button is clicked.
     */
    public void onStopAnimation(View view) {
        if (!checkReady()) {
            return;
        }

        map.stopAnimation();
    }

    /**
     * Called when the zoom in button (the one with the +) is clicked.
     */
    public void onZoomIn(View view) {
        if (!checkReady()) {
            return;
        }

        changeCamera(CameraUpdateFactory.zoomIn());
    }

    /**
     * Called when the zoom out button (the one with the -) is clicked.
     */
    public void onZoomOut(View view) {
        if (!checkReady()) {
            return;
        }

        changeCamera(CameraUpdateFactory.zoomOut());
    }

    /**
     * Called when the tilt more button (the one with the /) is clicked.
     */
    public void onTiltMore(View view) {
        if (!checkReady()) {
            return;
        }

        CameraPosition currentCameraPosition = map.getCameraPosition();
        float currentTilt = currentCameraPosition.tilt;
        float newTilt = currentTilt + 10;

        newTilt = (newTilt > 90) ? 90 : newTilt;

        CameraPosition cameraPosition = new CameraPosition.Builder(currentCameraPosition)
                .tilt(newTilt).build();

        changeCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
    }

    /**
     * Called when the tilt less button (the one with the \) is clicked.
     */
    public void onTiltLess(View view) {
        if (!checkReady()) {
            return;
        }

        CameraPosition currentCameraPosition = map.getCameraPosition();

        float currentTilt = currentCameraPosition.tilt;

        float newTilt = currentTilt - 10;
        newTilt = (newTilt > 0) ? newTilt : 0;

        CameraPosition cameraPosition = new CameraPosition.Builder(currentCameraPosition)
                .tilt(newTilt).build();

        changeCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
    }

    /**
     * Called when the left arrow button is clicked. This causes the camera to move to the left
     */
    public void onScrollLeft(View view) {
        if (!checkReady()) {
            return;
        }

        changeCamera(CameraUpdateFactory.scrollBy(-SCROLL_BY_PX, 0));
    }

    /**
     * Called when the right arrow button is clicked. This causes the camera to move to the right.
     */
    public void onScrollRight(View view) {
        if (!checkReady()) {
            return;
        }

        changeCamera(CameraUpdateFactory.scrollBy(SCROLL_BY_PX, 0));
    }

    /**
     * Called when the up arrow button is clicked. The causes the camera to move up.
     */
    public void onScrollUp(View view) {
        if (!checkReady()) {
            return;
        }

        changeCamera(CameraUpdateFactory.scrollBy(0, -SCROLL_BY_PX));
    }

    /**
     * Called when the down arrow button is clicked. This causes the camera to move down.
     */
    public void onScrollDown(View view) {
        if (!checkReady()) {
            return;
        }

        changeCamera(CameraUpdateFactory.scrollBy(0, SCROLL_BY_PX));
    }

    /**
     * Called when the animate button is toggled
     */
    public void onToggleAnimate(View view) {
        updateEnabledState();
    }

    /**
     * Called when the custom duration checkbox is toggled
     */
    public void onToggleCustomDuration(View view) {
        updateEnabledState();
    }

    /**
     * Update the enabled state of the custom duration controls.
     */
    private void updateEnabledState() {
        customDurationToggle.setEnabled(animateToggle.isChecked());
        customDurationBar
                .setEnabled(animateToggle.isChecked() && customDurationToggle.isChecked());
    }

    private void changeCamera(CameraUpdate update) {
        changeCamera(update, null);
    }

    /**
     * Change the camera position by moving or animating the camera depending on the state of the
     * animate toggle button.
     */
    private void changeCamera(CameraUpdate update, CancelableCallback callback) {
        if (animateToggle.isChecked()) {
            if (customDurationToggle.isChecked()) {
                int duration = customDurationBar.getProgress();
                // The duration must be strictly positive so we make it at least 1.
                map.animateCamera(update, Math.max(duration, 1), callback);
            } else {
                map.animateCamera(update, callback);
            }
        } else {
            map.moveCamera(update);
        }
    }

    @Override
    public void onCameraMoveStarted(int reason) {
        if (!isCanceled) {
            map.clear();
        }

        String reasonText = "UNKNOWN_REASON";
        currPolylineOptions = new PolylineOptions().width(5);
        switch (reason) {
            case OnCameraMoveStartedListener.REASON_GESTURE:
                currPolylineOptions.color(Color.BLUE);
                reasonText = "GESTURE";
                break;
            case OnCameraMoveStartedListener.REASON_API_ANIMATION:
                currPolylineOptions.color(Color.RED);
                reasonText = "API_ANIMATION";
                break;
            case OnCameraMoveStartedListener.REASON_DEVELOPER_ANIMATION:
                currPolylineOptions.color(Color.GREEN);
                reasonText = "DEVELOPER_ANIMATION";
                break;
        }
        Log.d(TAG, "onCameraMoveStarted(" + reasonText + ")");
        addCameraTargetToPath();
    }

    @Override
    public void onCameraMove() {
        // When the camera is moving, add its target to the current path we'll draw on the map.
        if (currPolylineOptions != null) {
            addCameraTargetToPath();
        }
        Log.d(TAG, "onCameraMove");
    }

    @Override
    public void onCameraMoveCanceled() {
        // When the camera stops moving, add its target to the current path, and draw it on the map.
        if (currPolylineOptions != null) {
            addCameraTargetToPath();
            map.addPolyline(currPolylineOptions);
        }
        isCanceled = true;  // Set to clear the map when dragging starts again.
        currPolylineOptions = null;
        Log.d(TAG, "onCameraMoveCancelled");
    }

    @Override
    public void onCameraIdle() {
        if (currPolylineOptions != null) {
            addCameraTargetToPath();
            map.addPolyline(currPolylineOptions);
        }
        currPolylineOptions = null;
        isCanceled = false;  // Set to *not* clear the map when dragging starts again.
        Log.d(TAG, "onCameraIdle");
    }

    private void addCameraTargetToPath() {
        LatLng target = map.getCameraPosition().target;
        currPolylineOptions.add(target);
    }
}

নিম্নলিখিত ক্যামেরা শ্রোতা উপলব্ধ:

  • ক্যামেরা চলতে শুরু করলে OnCameraMoveStartedListener এর onCameraMoveStarted() কলব্যাক ডাকা হয়। কলব্যাক পদ্ধতি ক্যামেরা গতির একটি reason গ্রহণ করে। কারণটি নিম্নলিখিতগুলির মধ্যে একটি হতে পারে:

    • REASON_GESTURE নির্দেশ করে যে ম্যাপে ব্যবহারকারীর অঙ্গভঙ্গির প্রতিক্রিয়া হিসাবে ক্যামেরা সরানো হয়েছে, যেমন প্যানিং, কাত করা, জুম করার জন্য চিমটি করা, বা মানচিত্রটি ঘোরানো।
    • REASON_API_ANIMATION ইঙ্গিত করে যে API একটি নন-ইঙ্গিত ব্যবহারকারীর ক্রিয়াকলাপের প্রতিক্রিয়া হিসাবে ক্যামেরাটিকে সরিয়ে দিয়েছে, যেমন জুম বোতামে আলতো চাপ দেওয়া, আমার অবস্থান বোতামে আলতো চাপ দেওয়া বা একটি মার্কারে ক্লিক করা৷
    • REASON_DEVELOPER_ANIMATION নির্দেশ করে যে আপনার অ্যাপ ক্যামেরা মুভমেন্ট শুরু করেছে।
  • OnCameraMoveListener এর onCameraMove() কলব্যাকটি একাধিকবার আহ্বান করা হয় যখন ক্যামেরা চলমান থাকে বা ব্যবহারকারী টাচ স্ক্রিনের সাথে ইন্টারঅ্যাক্ট করছে। কত ঘন ঘন কলব্যাক আহ্বান করা হয় তার একটি নির্দেশিকা হিসাবে, এটি জানা দরকারী যে API প্রতি ফ্রেমে একবার কলব্যাক আহ্বান করে৷ মনে রাখবেন, যাইহোক, এই কলব্যাকটি অ্যাসিঙ্ক্রোনাসভাবে আহ্বান করা হয়েছে এবং তাই স্ক্রীনে যা দেখা যাচ্ছে তার সাথে সিঙ্কের বাইরে। এছাড়াও মনে রাখবেন যে একটি onCameraMove() কলব্যাক এবং পরেরটির মধ্যে ক্যামেরা অবস্থান অপরিবর্তিত থাকা সম্ভব।

  • OnCameraIdleListener এর OnCameraIdle() কলব্যাকটি চালু করা হয় যখন ক্যামেরা নড়াচড়া করা বন্ধ করে দেয় এবং ব্যবহারকারী মানচিত্রের সাথে ইন্টারঅ্যাক্ট করা বন্ধ করে দেয়।

  • বর্তমান ক্যামেরা চলাচল বাধাগ্রস্ত হলে OnCameraMoveCanceledListener এর OnCameraMoveCanceled() কলব্যাক আহ্বান করা হয়। OnCameraMoveCanceled() কলব্যাকের পরপরই, onCameraMoveStarted() কলব্যাকটি নতুন reason সাথে আহ্বান করা হয়।

    যদি আপনার অ্যাপটি স্পষ্টভাবে GoogleMap.stopAnimation() কল করে, তাহলে OnCameraMoveCanceled() কলব্যাক আহ্বান করা হবে, কিন্তু onCameraMoveStarted() কলব্যাকটি আহ্বান করা হবে না

মানচিত্রে একজন শ্রোতা সেট করতে, প্রাসঙ্গিক সেট-লিসেনার পদ্ধতিতে কল করুন। উদাহরণস্বরূপ, OnCameraMoveStartedListener থেকে একটি কলব্যাকের অনুরোধ করতে, GoogleMap.setOnCameraMoveStartedListener() কে কল করুন।

আপনি CameraPosition থেকে ক্যামেরার লক্ষ্য (অক্ষাংশ/দ্রাঘিমাংশ), জুম, বিয়ারিং এবং টিল্ট পেতে পারেন। এই বৈশিষ্ট্যগুলি সম্পর্কে বিস্তারিত জানার জন্য ক্যামেরা অবস্থান নির্দেশিকা দেখুন।

ব্যবসা এবং আগ্রহের অন্যান্য পয়েন্টের ইভেন্ট

ডিফল্টরূপে, আগ্রহের পয়েন্টগুলি (POIs) তাদের সংশ্লিষ্ট আইকনগুলির সাথে বেস মানচিত্রে উপস্থিত হয়৷ POI গুলির মধ্যে পার্ক, স্কুল, সরকারি ভবন এবং আরও অনেক কিছুর পাশাপাশি ব্যবসায়িক POI যেমন দোকান, রেস্তোরাঁ এবং হোটেল অন্তর্ভুক্ত রয়েছে৷

আপনি একটি POI-তে ক্লিক ইভেন্টগুলিতে প্রতিক্রিয়া জানাতে পারেন। ব্যবসার নির্দেশিকা এবং অন্যান্য আগ্রহের পয়েন্ট দেখুন।

ইনডোর ম্যাপ ইভেন্ট

আপনি একটি ইনডোর মানচিত্রের সক্রিয় স্তর খুঁজে পেতে এবং কাস্টমাইজ করতে ইভেন্টগুলি ব্যবহার করতে পারেন৷ যখন একটি নতুন বিল্ডিং ফোকাস করা হয় বা একটি বিল্ডিংয়ে একটি নতুন স্তর সক্রিয় করা হয় তখন একটি শ্রোতাকে কল করার জন্য সেট করতে OnIndoorStateChangeListener ইন্টারফেস ব্যবহার করুন৷

GoogleMap.getFocusedBuilding() কল করে বর্তমানে ফোকাসে থাকা বিল্ডিংটি পান। মানচিত্রটিকে একটি নির্দিষ্ট ল্যাট/লং-এ কেন্দ্রীভূত করলে সাধারণত আপনাকে সেই ল্যাট/লং-এ বিল্ডিং দেওয়া হবে, কিন্তু এটি নিশ্চিত নয়।

আপনি IndoorBuilding.getActiveLevelIndex() কল করে বর্তমানে সক্রিয় স্তরটি খুঁজে পেতে পারেন।

কোটলিন



map.focusedBuilding?.let { building: IndoorBuilding ->
    val activeLevelIndex = building.activeLevelIndex
    val activeLevel = building.levels[activeLevelIndex]
}

      

জাভা


IndoorBuilding building = map.getFocusedBuilding();
if (building != null) {
    int activeLevelIndex = building.getActiveLevelIndex();
    IndoorLevel activeLevel = building.getLevels().get(activeLevelIndex);
}

      

আপনি যদি সক্রিয় স্তরের জন্য কাস্টম মার্কআপ দেখাতে চান, যেমন মার্কার , গ্রাউন্ড ওভারলে , টাইল ওভারলে , বহুভুজ, পলিলাইন এবং অন্যান্য আকার দেখাতে চান তাহলে এটি কার্যকর।

ইঙ্গিত: রাস্তার স্তরে ফিরে যেতে, IndoorBuilding.getDefaultLevelIndex() এর মাধ্যমে ডিফল্ট স্তরটি পান এবং IndoorLevel.activate() এর মাধ্যমে এটিকে সক্রিয় স্তর হিসাবে সেট করুন।

চিহ্নিতকারী এবং তথ্য উইন্ডো ঘটনা

আপনি মার্কার ক্লিক এবং ড্র্যাগ ইভেন্ট সহ মার্কার ইভেন্টগুলি শুনতে এবং প্রতিক্রিয়া জানাতে পারেন, GoogleMap অবজেক্টে সংশ্লিষ্ট শ্রোতা সেট করে যার সাথে মার্কার রয়েছে৷ মার্কার ইভেন্টের নির্দেশিকা দেখুন।

এছাড়াও আপনি তথ্য উইন্ডোতে ইভেন্ট শুনতে পারেন।

আকৃতি এবং ওভারলে ঘটনা

আপনি পলিলাইন , বহুভুজ , বৃত্ত এবং গ্রাউন্ড ওভারলেতে ক্লিক ইভেন্ট শুনতে এবং প্রতিক্রিয়া জানাতে পারেন।

অবস্থান ঘটনা

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

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

বিস্তারিত জানার জন্য, আমার অবস্থান স্তরের নির্দেশিকা দেখুন।