PDA

View Full Version : مشکل در رسم نقطه فعلی بر روی گوگل



mj_programmer
چهارشنبه 22 فروردین 1397, 10:48 صبح
سلام رفقا وقت بخیر ببخشید یه سوال دارم من دارم نقطه فعلی که شخص هست رو رو نقشه رسم میکنم مشکلی که دارم اینه نمیدانم چرا تا اولش جی پی اس رو روشن میکنم چند بار بالا پایینرسم میکنه یعنی خطی خطی میکنه بعد درست میشه ( ثابت میشه )! میخوام بدانم چطور میشه اولش که شروع به رسم میکنم جابجا نشه ! در صورتی که من ثابت هستم بعد شروع به حرکت کردم اون موقع خط آبی رو رسم کنه با تشکر
------
کد دریافت نقاط از جی پی اس و قرار دادن در آرایه point : -----از یه سرویس استفاده کردم که اگر برنامه بسته بود بکگروند نقاط رو بریزه تو آرایه بعد که دوباره صفحه نقشه لود بشه نقاطی که داخل ارایه هست رو رسم کنه!
public class MyService extends Service {
private SimpleLocation location;
double latitude, longitude;


@SuppressLint("WrongConstant")
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
try {
location = new SimpleLocation(this);
latitude = location.getLatitude();
longitude = location.getLongitude();
location.setListener(new SimpleLocation.Listener() {

public void onPositionChanged() {




LatLng latLng = new LatLng(latitude, longitude); //you already have this

MapFragment.points.add(latLng); //added
}

});


}
catch (NullPointerException e){

}
return Service.START_FLAG_REDELIVERY;
}

@Override
public IBinder onBind(Intent intent) {
return null;
}




}کد رسم خط آبی در دویداد private LocationListener mLocationListener = new LocationListener() { نوشتم :
private void redrawLine(){

//clears all Markers and Polylines


PolylineOptions options = new PolylineOptions().width(5).color(Color.BLUE).geode sic(true);
for (int i = 0; i < points.size(); i++) {
LatLng point = points.get(i);
options.add(point);
}


map.addPolyline(options); //add Polyline

}
147918