Skip to content

Commit

Permalink
Pridan oponent a finish do mapy
Browse files Browse the repository at this point in the history
  • Loading branch information
Saljack committed Nov 8, 2012
1 parent a34c318 commit 0f3ac10
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 8 deletions.
Binary file added res/drawable/finish.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable/opponent.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 9 additions & 8 deletions src/cz/cvut/fel/nur/zavody/activity/NormalMode.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.google.android.maps.MapView;
import com.google.android.maps.MyLocationOverlay;
import cz.cvut.fel.nur.zavody.R;
import cz.cvut.fel.nur.zavody.maps.RaceOverlays;

/**
*
Expand All @@ -34,8 +35,7 @@ public void onCreate(Bundle icicle) {
_mapView = (MapView) findViewById(R.id.nm_map);
_mapView.setBuiltInZoomControls(true);
_controller = _mapView.getController();
_myLocationOverlay = new MyLocationOverlay(this, _mapView)
{
_myLocationOverlay = new MyLocationOverlay(this, _mapView) {
@Override
public synchronized void onLocationChanged(Location location) {
super.onLocationChanged(location);
Expand All @@ -44,20 +44,21 @@ public synchronized void onLocationChanged(Location location) {
GeoPoint point = new GeoPoint(lat, lng);
_controller.animateTo(point);
}



@Override
protected void drawMyLocation(Canvas arg0, MapView arg1, Location arg2, GeoPoint arg3, long arg4) {
super.drawMyLocation(arg0, arg1, arg2, arg3, arg4);

}
};

_controller.setZoom(17);
_mapView.getOverlays().add(_myLocationOverlay);

_mapView.invalidate();
RaceOverlays raceOverlays = new RaceOverlays(getResources().getDrawable(R.drawable.ic_launcher), this);
_mapView.getOverlays().add(raceOverlays);


// _mapView.invalidate();

}

Expand Down
37 changes: 37 additions & 0 deletions src/cz/cvut/fel/nur/zavody/maps/FinishOverlay.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package cz.cvut.fel.nur.zavody.maps;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.Log;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.OverlayItem;
import cz.cvut.fel.nur.zavody.R;

/**
*
* @author saljack
*/
public class FinishOverlay extends OverlayItem {

public static final int LATITUDE = (int) (14.516599 * 1E6);
public static final int LONGITUDE = (int) (50.084988 * 1E6);
private Context _ctx;
private Drawable _marker;

public FinishOverlay(Context ctx) {
super(new GeoPoint(LONGITUDE, LATITUDE), "Opponent", "Opponent position");
_ctx = ctx;
_marker = _ctx.getResources().getDrawable(R.drawable.finish);
_marker.setBounds(0 - _marker.getIntrinsicWidth() / 2, 0 - _marker.getIntrinsicHeight(),
_marker.getIntrinsicWidth() / 2, 0);
}

@Override
public Drawable getMarker(int arg0) {
return _marker;
}
}
39 changes: 39 additions & 0 deletions src/cz/cvut/fel/nur/zavody/maps/OpponentOverlay.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package cz.cvut.fel.nur.zavody.maps;

import android.content.Context;
import android.graphics.drawable.Drawable;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.OverlayItem;
import cz.cvut.fel.nur.zavody.R;

/**
*
* //testing coordinates Heldova 50°5'5.671"N, 14°30'52.475"E Oponent
* 50°5'4.328"N, 14°30'50.703"E Finish 50°5'7.458"N, 14°30'47.161"E
*
* @author saljack
*/
public class OpponentOverlay extends OverlayItem {

public static final int LATITUDE = (int) (14.513599 * 1E6);
public static final int LONGITUDE = (int) (50.084688 * 1E6);
private Context _ctx;
private Drawable _marker;

public OpponentOverlay(Context ctx) {
super(new GeoPoint(LONGITUDE, LATITUDE), "Opponent", "Opponent position");
_ctx = ctx;
_marker = _ctx.getResources().getDrawable(R.drawable.opponent);
_marker.setBounds(0 - _marker.getIntrinsicWidth() / 2, 0 - _marker.getIntrinsicHeight(),
_marker.getIntrinsicWidth() / 2, 0);
}

@Override
public Drawable getMarker(int arg0) {
return _marker;
}
}
49 changes: 49 additions & 0 deletions src/cz/cvut/fel/nur/zavody/maps/RaceOverlays.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package cz.cvut.fel.nur.zavody.maps;

import android.content.Context;
import android.graphics.drawable.Drawable;
import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.OverlayItem;
import java.util.ArrayList;
import java.util.List;

/**
*
* @author saljack
*/
public class RaceOverlays extends ItemizedOverlay<OverlayItem> {

private Context _ctx;
private List<OverlayItem> _items = new ArrayList<OverlayItem>(2);

public RaceOverlays(Drawable marker, Context ctx) {
super(boundCenterBottom(marker));
_ctx = ctx;
_items.add(new FinishOverlay(ctx));
_items.add(new OpponentOverlay(ctx));
populate();
}

public void add(OverlayItem item) {
_items.add(item);
populate();
}

@Override
protected OverlayItem createItem(int i) {
// OverlayItem item = _items.get(i);
// Drawable marker = item.getMarker(0);
// boundCenterBottom(marker);
// item.setMarker(marker);
return _items.get(i);
}

@Override
public int size() {
return _items.size();
}
}

0 comments on commit 0f3ac10

Please sign in to comment.