Skip to content

Commit

Permalink
Ajeitando problema do marker duplicado
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro Cortez committed Jul 25, 2015
1 parent ee636d3 commit 867729c
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions app/src/main/java/com/tormentaLabs/riobus/model/MapMarker.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.LatLngBounds;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.gson.Gson;
import com.tormentaLabs.riobus.R;
Expand All @@ -22,7 +23,7 @@ public class MapMarker {

private GoogleMap map;
private LatLngBounds.Builder builder;
MarkerOptions userMarker;
Marker userMarker;

public MapMarker(GoogleMap map){
this.map = map;
Expand All @@ -49,16 +50,16 @@ private MarkerOptions getMarker(Bus bus) {
}

public void markUserPosition(Context context, LatLng posicao) {
if (userMarker == null) {
userMarker = new MarkerOptions()
.position(posicao)
.title(context.getString(R.string.marker_user))
.icon(BitmapDescriptorFactory
.fromResource(R.drawable.man_maps));
} else {
userMarker.position(posicao);

if (userMarker != null) {
userMarker.remove();
}
map.addMarker(userMarker);

userMarker = map.addMarker(new MarkerOptions()
.position(posicao)
.title(context.getString(R.string.marker_user))
.icon(BitmapDescriptorFactory
.fromResource(R.drawable.man_maps)));
}


Expand Down

0 comments on commit 867729c

Please sign in to comment.