मैप में 3D मॉडल जोड़ना

प्लैटफ़ॉर्म चुनें: Android iOS JavaScript

मैप पर मौजूद 3D मॉडल

यहां दिए गए कोड सैंपल में, addModel तरीके को कॉल करके, 3D मॉडल जोड़ने और उसे 3D स्पेस में रखने का तरीका बताया गया है. इस कोड सैंपल का इस्तेमाल करने के लिए, सेटअप और अपने ऐप्लिकेशन में 3D मैप जोड़ना में दिए गए निर्देशों का पालन करें. इससे, Android Studio प्रोजेक्ट को बुनियादी 3D मैप के साथ सेट अप किया जा सकेगा. इसके बाद, MainActivity.kt फ़ाइल में यह कोड जोड़ें:

// Add imports and define constants
import com.google.android.gms.maps3d.model.latLngAltitude
val PLANE_URL = "https://storage.googleapis.com/gmp-maps-demos/p3d-map/assets/Airplane.glb"
val PLANE_SCALE = 0.05

// Add to the onMap3DViewReady method, after the googleMap3D object has been initialized
googleMap3D.setCamera(
   camera {
        center = latLngAltitude {
            latitude = 47.133971
            longitude = 11.333161
            altitude = 2200.0
        }
        heading = 221.0
        tilt = 65.0
        range = 1_200.0
    }
)

googleMap3D.addModel(
    modelOptions {
        id = "plane_model"
        position = latLngAltitude {
            latitude = 47.133971
            longitude = 11.333161
            altitude = 2200.0
        }
        altitudeMode = AltitudeMode.ABSOLUTE
        orientation = orientation {
            heading = 41.5
            tilt = -90.0
            roll = 0.0
        }
        url = PLANE_URL
        scale = vector3D {
            x = PLANE_SCALE
            y = PLANE_SCALE
            z = PLANE_SCALE
        }
    }
)