Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a Marker without adding it to the map? [closed]

  • How to create instance of Marker class, but without adding it to the map.
like image 359
Yordan Yanakiev Avatar asked May 10 '13 11:05

Yordan Yanakiev


People also ask

How do you move a map under a marker?

Just put RelativeLayout over MapFragment with android:layout_width="match_parent" android:layout_height="wrap_content" ImageView with marker picture (it should be like png with transparent layer and marker image itself should be on the top half of image) and set centerInParent="true" for it.

What is a marker on a map?

A marker identifies a location on a map. By default, a marker uses a standard image. Markers can display custom images, in which case they are usually referred to as "icons." Markers and icons are objects of type Marker .


2 Answers

You may use LazyMarker.java from Android Maps Extensions.

It doesn't physically create marker until you call setVisible(true) on it.

like image 105
MaciejGórski Avatar answered Sep 22 '22 21:09

MaciejGórski


You can do this by setting the visibility to false

Marker marker = mMap.addMarker(new MarkerOptions()
                            .position(
                                    new LatLng(arg0.latitude,
                                            arg0.longitude))
                            .draggable(true).visible(false));

Edit

Marker m = new Marker(new z() {

                @Override
                public IBinder asBinder() {
                    return null;
                }

                @Override
                public void showInfoWindow() throws RemoteException {

                }

                @Override
                public void setVisible(boolean paramBoolean)
                        throws RemoteException {

                }

                @Override
                public void setTitle(String paramString)
                        throws RemoteException {

                }

                @Override
                public void setSnippet(String paramString)
                        throws RemoteException {

                }

                @Override
                public void setPosition(LatLng paramLatLng)
                        throws RemoteException {

                }

                @Override
                public void setDraggable(boolean paramBoolean)
                        throws RemoteException {

                }

                @Override
                public void remove() throws RemoteException {

                }

                @Override
                public boolean isVisible() throws RemoteException {
                    return false;
                }

                @Override
                public boolean isInfoWindowShown() throws RemoteException {
                    return false;
                }

                @Override
                public boolean isDraggable() throws RemoteException {
                    return false;
                }

                @Override
                public void hideInfoWindow() throws RemoteException {

                }

                @Override
                public int hashCodeRemote() throws RemoteException {
                    return 0;
                }

                @Override
                public String getTitle() throws RemoteException {
                    return null;
                }

                @Override
                public String getSnippet() throws RemoteException {
                    return null;
                }

                @Override
                public LatLng getPosition() throws RemoteException {
                    return null;
                }

                @Override
                public String getId() throws RemoteException {
                    return null;
                }

                @Override
                public boolean g(z paramz) throws RemoteException {
                    return false;
                }
            });

And then adding it when you want like this

mMap.addMarker(new MarkerOptions().position((m.getPosition())));

Hope it helps

like image 35
AnujMathur_07 Avatar answered Sep 24 '22 21:09

AnujMathur_07