简体   繁体   中英

Is it possible to use markers on street view in android Google maps API v2?

我在我的应用程序中实现了街景,我希望在街景中看到地图标记,这可能吗?

It's possible to add markers to StreetView in Android via a custom implementation.

You should put a transparent SurfaceView on top of your StreetView ,

Pass panorama. setOnStreetViewPanoramaCameraChangeListener (..) and panorama. setOnStreetViewPanoramaCameraChangeListener (..) to your surface view to update camera position and location .

Then calculate distance to the marker from your camera location, and azimuth from you to the marker.

Lastly calculate projection of those values to the screen - get view height, view width, etc. from your surface view, and draw your markers' bitmap to surface view's canvas .

Save those bitmaps to a HashMap to avoid loading same bitmap multiple times. This will make your draw thread run much faster. Later you will probably want to load markers' icons from your online source.

There's still going to be some delay and markers are going to tremble a bit, so smoothen their placement.

Don't forget to save your markers screen projection left top right bottom placement in a HashMap to implement click on markers.

You will then want to make them markers clickable .

override onTouchEvent ( .. ) in SurfaceView.

Save the position from the latest motion event in some field, then return false to pass the touch event to the underlying StreetView.

Implement panorama. setOnStreetViewPanoramaClickListener ( .. ) in the upper level - pass the click event to the SurfaceView, and you will know your click's x/y position from the saved field.

Loop through your markers' saved On Screen Position HashMap to know whether some marker was really clicked , if yes - return that event to the final listener in the upper level, and you will know when a marker was clicked

Check out the video to look how it turned out for my project - it took me 3 days to implement this feature [android] street view custom marker

I can't provide code samples here, but be free to ask

Nowadays Android Google maps API v2 can´t add markers, this option is only available for iOS.

Markers within Street View https://developers.google.com/maps/documentation/ios/streetview#markers_within_street_view

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM