question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Remove specific marker

See original GitHub issue

Hello I need to update a marker position, but i cant, this is my code. I`ve tried to put marker.remove() instruction but nothing happens.

              $(".startButton").click(function(){

                    /*

                    marker_tipe_a.remove();  //  I need a function like this:

                    marker.remove();  // Nothing happens 
                    map.marker.remove();  //nothing happens

                    */

                    map.getCameraPosition(function(camera){
                        map.addMarker({
                            'position': new plugin.google.maps.LatLng(camera.target.lat,camera.target.lng),
                            'icon': 'www/img/start.png'
                        }, function(marker) {

                        });
                    });

                })

                $(".endButton").click(function(){
                    map.marker.remove();

                })

Please help

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
ragavanrandycommented, Jun 25, 2018

i too have the same problem. the following are properties of the class,

markers = [{lat:40.730610,lng: -73.935242,title:'marker 1'},{lat:35.5175,lng: 86.5804,title:'marker 2'}]; arrayMarkers:Marker[];

and the following are the methods of the class,

//Place markers on the map
  addMarkers(){
    if (this.markers != null || this.markers != undefined) {
      this.markers.forEach((marker) => {
        this.map.addMarker({
          position: new LatLng(marker.lat,marker.lng),
          title: marker.title,
          animation: 'DROP',
        }).then((markerRef) => {
          this.arrayMarkers.push(markerRef);
          markerRef.on(GoogleMapsEvent.MARKER_CLICK)
            .subscribe(() => {
              alert(marker.getTitle);
            });
        });
      });
    }
  }

and

//remove markers from the map
  removeMarkers() {
    if(this.arrayMarkers !== undefined){
      this.arrayMarkers.forEach(marker => {
        marker.removeEventListener(GoogleMapsEvent.MARKER_CLICK);
        marker.remove();
      });
    }
  }

the addMarkers method working and add markers on map. But, the removeMarkers method not seems to remove the markers.

0reactions
samuelaj1commented, May 30, 2018

Set my location to true on the map e.g. GoogleMaps.create(‘map_canvas’,{ controls:{ myLocation:true } }

Read more comments on GitHub >

github_iconTop Results From Across the Web

Google Maps Api 3 Remove Selected Marker Only
To remove particular Marker,Find that Element Index using Unique Id for Each Marker. var MarkerIndex = MarkerArray.findIndex(function GetIndex( ...
Read more >
Removing Markers | Maps JavaScript API - Google Developers
This example creates a map where each click by the user creates a marker. Click the buttons to hide or delete all of...
Read more >
Google Maps V3 - Remove single marker - ASPSnippets
In this short article I will explain how to remove specific / single / selected marker on Button click in Google Maps V3....
Read more >
How to Remove Markers From Google Maps
Click the marker to reveal the editing options. Click the "Delete" link in the lower-left corner of the dialog box.
Read more >
Removing individual markers from map - GIS Stack Exchange
I couldn't get the layer to be removed, here are some solutions for how to remove individual markers. Share. Share a link to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found