我正在创建一个应用程序,我正在绘制从当前标记到附近标记的路线。当我点击附近的标记时它创建了一条路线,当我再次点击另一个标记时,前一条路线仍显示。所以我想删除以前的路线并绘制从当前标记到附近标记的新路线。请帮我使用我的源代码....
mMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() {
@Override
public View getInfoWindow(Marker arg0) {
return null;
}
@Override
public View getInfoContents(Marker marker) {
//for direction Route
if(CurrentMarker != null) {
LatLng origin = CurrentMarker.getPosition();
LatLng dest = marker.getPosition();
String url = getDirectionsUrl(origin, dest);
DownloadPar downloadPar = new DownloadPar();
// Start downloading json data from Google Directions API
downloadPar.execute(url);
}
View myContentsView = getLayoutInflater().inflate(R.layout.details, null);
TextView tvTitle = ((TextView)myContentsView.findViewById(R.id.title));
tvTitle.setText(marker.getTitle());
TextView tvSnippet = ((TextView)myContentsView.findViewById(R.id.snippet));
tvSnippet.setText(marker.getSnippet());
return myContentsView;
}
});
请帮帮我... 感谢
答案 0 :(得分:0)
protected void onPostExecute(List>> result){ ArrayList points = null;
NotificationCompat.Builder builder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("Notification")
.setContentText("Hello !!!")
.setDefaults(Notification.DEFAULT_ALL)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.addAction(R.drawable.ic_launcher,
"View Call", null)
.addAction(R.drawable.ic_launcher,
"Call Back", null);
// Gets an instance of the NotificationManager service
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, builder.build());
答案 1 :(得分:0)
声明变量:
private Polyline polyline;
然后在您最初将Polyline
添加到Map
:
polyline = mMap.addPolyline(lineOptions);
然后当你想要更新Polyline
时,我相信你可以使用:
polyline.setPoints(newPoints);
否则,请通过调用polyline.setMap(null)
删除折线,然后像上面所做的那样创建一个新折线。
有关Polyline
的详细信息,请参阅documentation