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

I have implemented street view in my application and I want to see map markers on the street, is this possible?


source to share

2 answers

At the present time Android Google maps API v2

can not add markers, this option is only available for iOS.

Street view markers



it is possible to add markers to StreetView on Android via custom implementation.

You have to place a transparent SurfaceView on top of the StreetView ,

Skip panorama. setOnStreetViewPanoramaCameraChangeListener (..) and panorama. set the OnStreetViewPanoramaCameraChangeListener (..) to your surface view to update the camera position and location .

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

Finally, compute a prediction of those values ​​on the screen - get the view height, view width, etc. from your surface view and paint a bitmap of your markers onto the surface view of the canvas .

Save these bitmaps in a HashMap to avoid loading the same bitmap multiple times. This will make the thread flow much faster. Later, you will probably want to download marker icons from your online source.

There will still be some kind of lag and the markers will jitter a little, so smoothing out their placement.

Remember to keep the screen projection with the markers in the upper left lower right place in the HashMap to implement clickable markers.

Then you will want to make the markers clickable .

override onTouchEvent (..) on SurfaceView.

Store the position from the last motion event in a field, then return false to pass the touch event to the underlying StreetView.

Implement a panorama. setOnStreetViewPanoramaClickListener (..) at the top level - pass the click event to the SurfaceView and you will know your x / y click from the saved field.

Finish saving the markers you saved. On the HashMap screen you will know if any marker is actually clickedif yes - return this event to the final listener at the top level and you will know when the marker was pressed

Watch the video to see how it turned out for my project - it took me 3 days to implement this feature Custom Marker [android] for Street View

I cannot provide code examples here, but one can ask



All Articles