簡體   English   中英

如何根據用戶當前位置在Google地圖上的事件和地點附近顯示

[英]How to display near by events and venues on google map based on user current location

在這里,我現在可以通過獲取用戶的緯度和經度來在Google地圖上顯示用戶,我想通過用戶位置中發生的事件來顯示用戶附近的位置,並希望顯示附近的地點,因此選擇了Foursquare API。 這是 第二個。這是我的代碼,用於在地圖上顯示用戶

        R.id.map)).getMap();
    // Creating location manager and location classes instances
    locationManager = (LocationManager) this
            .getSystemService(LOCATION_SERVICE);
    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0,
            0, this);
    ;
    mCurrentLocation = locationManager
            .getLastKnownLocation(LocationManager.GPS_PROVIDER);
    // if location found display as a toast the current latitude and
    // longitude
    if (mCurrentLocation != null) {

        Toast.makeText(
                this,
                "Current location:\nLatitude: "
                        + mCurrentLocation.getLatitude() + "\n"
                        + "Longitude: " + mCurrentLocation.getLongitude(),
                Toast.LENGTH_LONG).show();
        USER_LOCATION = new LatLng(mCurrentLocation.getLatitude(), mCurrentLocation.getLongitude());

        // adding marker
        googleMap.addMarker(new MarkerOptions().position(USER_LOCATION).icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_ROSE)).title("Your current location"));
         // Move the camera instantly to hamburg with a zoom of 15.
        googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(USER_LOCATION, 12));

        // Zoom in, animating the camera.
        googleMap.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null);

給我一個簡短的想法,如何基於我的代碼使用該api。

抱歉,您要復制和粘貼的完整教程嗎?

您設法找到了位置,並且擁有要使用的api的文檔...可以使用它嗎?

從Android獲取您的位置。 對其進行格式化,以便api可以使用它(也許他們需要坐標,也許是城市名稱,...),然后調用Web服務。 您將得到結果,並且必須對其進行解釋。

您的問題實際上在哪里?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM