/** The m_info paint. */\r
private static Paint m_infoPaint;\r
\r
+ private MyLocationOverlay m_myLocation;\r
+ \r
private RunningRoute m_route;\r
\r
static {\r
- (mapView.getLongitudeSpan() / 2);\r
int lonTo = gpCenter.getLongitudeE6()\r
+ (mapView.getLongitudeSpan() / 2);\r
+ GeoPoint prevGP = null;\r
+ GeoPoint currGP = null;\r
for (Iterator<GeoPoint> it = m_pointList.iterator(); it\r
.hasNext();) {\r
- GeoPoint gp = it.next();\r
-\r
- int lat = gp.getLatitudeE6();\r
- int lon = gp.getLongitudeE6();\r
- // 表示されない部分は描画しない\r
- if (lat < latFrom || lat > latTo || lon < lonFrom\r
- || lon > lonTo) {\r
- continue;\r
+ currGP = it.next();\r
+\r
+ int currLat = currGP.getLatitudeE6();\r
+ int currLon = currGP.getLongitudeE6();\r
+ \r
+ int prevLat = 0;\r
+ int prevLon = 0;\r
+ \r
+ if (prevGP != null) {\r
+ prevLat = prevGP.getLatitudeE6();\r
+ prevLon = prevGP.getLongitudeE6();\r
}\r
\r
- pxEnd = projection.toPixels(gp, null);\r
- if (pxStart != null) {\r
-\r
+ // 初回\r
+ if (prevGP == null) {\r
+ // 前回と今回の位置が画面外\r
+ } else if ((currLat < latFrom || currLat > latTo\r
+ || currLon < lonFrom || currLon > lonTo)\r
+ && (prevLat < latFrom || prevLat > latTo\r
+ || prevLon < lonFrom || prevLon > lonTo)) {\r
+ // TODO: 両端とも画面外だが画面内を通る場合を考慮\r
+ pxStart = null;\r
+ // 上記以外の場合は経路を描画\r
+ } else {\r
+ if (pxStart == null) {\r
+ pxStart = projection.toPixels(prevGP, null);\r
+ }\r
+ pxEnd = projection.toPixels(currGP, null);\r
canvas.drawLine(pxStart.x, pxStart.y, pxEnd.x, pxEnd.y,\r
m_routePaint);\r
+ pxStart = pxEnd;\r
}\r
-\r
- pxStart = pxEnd;\r
+ prevGP = currGP;\r
}\r
}\r
}\r
TextOverlay textOverlay = new TextOverlay(gp, rec.getName());\r
m_mapOverlays.add(textOverlay);\r
}\r
+ \r
}\r
\r
}\r
\r
m_mapOverlays = mapView.getOverlays();\r
\r
- m_route = new RunningRoute();\r
- m_mapOverlays.add(m_route);\r
-\r
drawOverlays(mapView);\r
}\r
\r
\r
m_mapOverlays.clear();\r
\r
- MyLocationOverlay myLocationOverlay = new MyLocationOverlay(this,\r
- mapView);\r
- myLocationOverlay.enableMyLocation();\r
-\r
- m_mapOverlays.add(myLocationOverlay);\r
+ m_route = new RunningRoute();\r
+ m_mapOverlays.add(m_route);\r
\r
Iterator<Record> it = TokyoRunners.getRecordIterator();\r
GeoPoint gp = null;\r
- RunningRoute route = new RunningRoute();\r
+// RunningRoute route = new RunningRoute();\r
while (it.hasNext()) {\r
Record rec = it.next();\r
if (rec.hasLocation()) {\r
gp = new GeoPoint(rec.getLatitudeE6(), rec.getLongitudeE6());\r
- route.addPoint(gp);\r
+ m_route.addPoint(gp);\r
\r
if (rec.getName().length() > 0) {\r
TextOverlay textOverlay = new TextOverlay(gp, rec.getName());\r
m_startTime = rec.getDate().getTime();\r
}\r
}\r
- m_mapOverlays.add(route);\r
+// m_mapOverlays.add(route);\r
if (gp != null) {\r
m_controller.setCenter(gp);\r
}\r
\r
+ m_myLocation = new MyLocationOverlay(this, mapView);\r
+ m_myLocation.enableMyLocation();\r
+\r
+ m_mapOverlays.add(m_myLocation);\r
+\r
}\r
\r
/*\r
startActivity(intent);\r
break;\r
case Constants.MENU_HERE:\r
- LocationManager locMgr = (LocationManager) getSystemService(Context.LOCATION_SERVICE);\r
- Location loc = locMgr\r
- .getLastKnownLocation(LocationManager.GPS_PROVIDER);\r
- if (loc != null) {\r
- GeoPoint gp = new GeoPoint((int) (loc.getLatitude() * 1E6),\r
- (int) (loc.getLongitude() * 1E6));\r
+ GeoPoint gp = m_myLocation.getMyLocation();\r
+ if (gp != null) {\r
m_controller.animateTo(gp);\r
}\r
break;\r