How to remove custom marker from open street map and reload it again?











up vote
1
down vote

favorite












Here is my code. I can load marker using this method.But i want to load another marker at the same place, so i tried to remove older and put new one.



private void locationFind(String latitude, String longitude) {

Double latDouble = Double.parseDouble(latitudeStr);
Double lanDouble = Double.parseDouble(longitudeStr);

marker = new Marker(mapView, getContext());
marker.setPosition(new GeoPoint(latDouble - .001, lanDouble + .001));
marker.setIcon(new BitmapDrawable(createCustomMarker(1)));
marker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
mapView.getOverlays().add(marker);
marker.setOnMarkerClickListener(new Marker.OnMarkerClickListener() {
@Override
public boolean onMarkerClick(Marker marker, MapView mapView) {
marker.closeInfoWindow();
return false;
}
});
mapView.getOverlays().add(marker);
}
}









share|improve this question









New contributor




Md. Atikur Rahman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • googleMap.clear(); and add again
    – Zahoor Saleem
    Nov 10 at 16:26










  • Try mapView.getOverlays().remove(marker) to remove the marker overlay, or remove all overlay objects with mapView.getOverlays().clear().
    – elmiomar
    Nov 10 at 17:35















up vote
1
down vote

favorite












Here is my code. I can load marker using this method.But i want to load another marker at the same place, so i tried to remove older and put new one.



private void locationFind(String latitude, String longitude) {

Double latDouble = Double.parseDouble(latitudeStr);
Double lanDouble = Double.parseDouble(longitudeStr);

marker = new Marker(mapView, getContext());
marker.setPosition(new GeoPoint(latDouble - .001, lanDouble + .001));
marker.setIcon(new BitmapDrawable(createCustomMarker(1)));
marker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
mapView.getOverlays().add(marker);
marker.setOnMarkerClickListener(new Marker.OnMarkerClickListener() {
@Override
public boolean onMarkerClick(Marker marker, MapView mapView) {
marker.closeInfoWindow();
return false;
}
});
mapView.getOverlays().add(marker);
}
}









share|improve this question









New contributor




Md. Atikur Rahman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • googleMap.clear(); and add again
    – Zahoor Saleem
    Nov 10 at 16:26










  • Try mapView.getOverlays().remove(marker) to remove the marker overlay, or remove all overlay objects with mapView.getOverlays().clear().
    – elmiomar
    Nov 10 at 17:35













up vote
1
down vote

favorite









up vote
1
down vote

favorite











Here is my code. I can load marker using this method.But i want to load another marker at the same place, so i tried to remove older and put new one.



private void locationFind(String latitude, String longitude) {

Double latDouble = Double.parseDouble(latitudeStr);
Double lanDouble = Double.parseDouble(longitudeStr);

marker = new Marker(mapView, getContext());
marker.setPosition(new GeoPoint(latDouble - .001, lanDouble + .001));
marker.setIcon(new BitmapDrawable(createCustomMarker(1)));
marker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
mapView.getOverlays().add(marker);
marker.setOnMarkerClickListener(new Marker.OnMarkerClickListener() {
@Override
public boolean onMarkerClick(Marker marker, MapView mapView) {
marker.closeInfoWindow();
return false;
}
});
mapView.getOverlays().add(marker);
}
}









share|improve this question









New contributor




Md. Atikur Rahman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











Here is my code. I can load marker using this method.But i want to load another marker at the same place, so i tried to remove older and put new one.



private void locationFind(String latitude, String longitude) {

Double latDouble = Double.parseDouble(latitudeStr);
Double lanDouble = Double.parseDouble(longitudeStr);

marker = new Marker(mapView, getContext());
marker.setPosition(new GeoPoint(latDouble - .001, lanDouble + .001));
marker.setIcon(new BitmapDrawable(createCustomMarker(1)));
marker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
mapView.getOverlays().add(marker);
marker.setOnMarkerClickListener(new Marker.OnMarkerClickListener() {
@Override
public boolean onMarkerClick(Marker marker, MapView mapView) {
marker.closeInfoWindow();
return false;
}
});
mapView.getOverlays().add(marker);
}
}






android openstreetmap marker






share|improve this question









New contributor




Md. Atikur Rahman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Md. Atikur Rahman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Nov 10 at 16:23









Machavity

23.9k135478




23.9k135478






New contributor




Md. Atikur Rahman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Nov 10 at 16:06









Md. Atikur Rahman

61




61




New contributor




Md. Atikur Rahman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Md. Atikur Rahman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Md. Atikur Rahman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • googleMap.clear(); and add again
    – Zahoor Saleem
    Nov 10 at 16:26










  • Try mapView.getOverlays().remove(marker) to remove the marker overlay, or remove all overlay objects with mapView.getOverlays().clear().
    – elmiomar
    Nov 10 at 17:35


















  • googleMap.clear(); and add again
    – Zahoor Saleem
    Nov 10 at 16:26










  • Try mapView.getOverlays().remove(marker) to remove the marker overlay, or remove all overlay objects with mapView.getOverlays().clear().
    – elmiomar
    Nov 10 at 17:35
















googleMap.clear(); and add again
– Zahoor Saleem
Nov 10 at 16:26




googleMap.clear(); and add again
– Zahoor Saleem
Nov 10 at 16:26












Try mapView.getOverlays().remove(marker) to remove the marker overlay, or remove all overlay objects with mapView.getOverlays().clear().
– elmiomar
Nov 10 at 17:35




Try mapView.getOverlays().remove(marker) to remove the marker overlay, or remove all overlay objects with mapView.getOverlays().clear().
– elmiomar
Nov 10 at 17:35












1 Answer
1






active

oldest

votes

















up vote
0
down vote













Try this in the same thread



mapView.getOverlayManager().clear() ;
MapView.invalidate();



Then add..






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });






    Md. Atikur Rahman is a new contributor. Be nice, and check out our Code of Conduct.










     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53240791%2fhow-to-remove-custom-marker-from-open-street-map-and-reload-it-again%23new-answer', 'question_page');
    }
    );

    Post as a guest
































    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    Try this in the same thread



    mapView.getOverlayManager().clear() ;
    MapView.invalidate();



    Then add..






    share|improve this answer

























      up vote
      0
      down vote













      Try this in the same thread



      mapView.getOverlayManager().clear() ;
      MapView.invalidate();



      Then add..






      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        Try this in the same thread



        mapView.getOverlayManager().clear() ;
        MapView.invalidate();



        Then add..






        share|improve this answer












        Try this in the same thread



        mapView.getOverlayManager().clear() ;
        MapView.invalidate();



        Then add..







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 10 at 17:38









        XnaijaZ

        627




        627






















            Md. Atikur Rahman is a new contributor. Be nice, and check out our Code of Conduct.










             

            draft saved


            draft discarded


















            Md. Atikur Rahman is a new contributor. Be nice, and check out our Code of Conduct.













            Md. Atikur Rahman is a new contributor. Be nice, and check out our Code of Conduct.












            Md. Atikur Rahman is a new contributor. Be nice, and check out our Code of Conduct.















             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53240791%2fhow-to-remove-custom-marker-from-open-street-map-and-reload-it-again%23new-answer', 'question_page');
            }
            );

            Post as a guest




















































































            Popular posts from this blog

            List item for chat from Array inside array React Native

            Thiostrepton

            Caerphilly