asmani.imane
Messages postés1Date d'inscriptionvendredi 6 janvier 2017StatutMembreDernière intervention 6 janvier 2017
-
Modifié par BunoCS le 9/01/2017 à 13:03
BunoCS
Messages postés15495Date d'inscriptionlundi 11 juillet 2005StatutModérateurDernière intervention23 octobre 2024
-
10 janv. 2017 à 10:14
bonsoir je suis en train de faire une application android (je suis une débutante) pour faire une map et tracer des lignes entre les villes sur cette map , j'ai un problème avec width !! et je ne sais pas pourquoi !!!
Merci d'avance .
Voici mon code :
package com.example.pc.mapapp;
import android.graphics.Color;
import android.graphics.*;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import java.lang.Object;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.gms.maps.model.Polyline;
import com.google.android.gms.maps.model.PolylineOptions;
import android.*;
public class MainActivity extends AppCompatActivity implements OnMapReadyCallback {
private GoogleMap Map;
LatLng Cité_Boussouf = new LatLng(36.3300616, 6.5750984);
LatLng Cité_Ziadia = new LatLng(36.3820173, 6.6343742);
LatLng CHU = new LatLng(36.3725184, 6.6175108);
LatLng Musée = new LatLng(36.3627963, 6.6050246);
LatLng Elkhroub = new LatLng(36.2733076, 6.6857903);
LatLng université_2 = new LatLng(36.2446906, 6.5666261);
LatLng Centre_Culturel = new LatLng(36.3638029, 6.6058859);
LatLng université_3 = new LatLng(36.2779011, 6.5868009);
LatLng Cité_Bekira = new LatLng(36.3963102, 6.5402984);
LatLng Ville_Zighoud = new LatLng(36.5309942, 6.701599);
LatLng Aéroport = new LatLng(36.2839612, 6.6191946);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
/*
public PolylineOptions color(int color) {
return color(color);
}
public float getWidth() {
return 5;
}
*/
@Override
public void onMapReady(GoogleMap googleMap) {
Map.moveCamera(CameraUpdateFactory.newLatLngZoom(Cité_Boussouf ,15));
Map.animateCamera(CameraUpdateFactory.zoomTo(10),2000,null);
Map = googleMap;
Map.addMarker(new MarkerOptions().position(Cité_Boussouf).title("Cité_Boussouf"));
Map.moveCamera(CameraUpdateFactory.newLatLng(Cité_Boussouf));
Map.addMarker(new MarkerOptions().position(Cité_Ziadia).title("Cité_Ziadia"));
Map.moveCamera(CameraUpdateFactory.newLatLng(Cité_Ziadia));
Map.addMarker(new MarkerOptions().position(CHU).title("CHU"));
Map.moveCamera(CameraUpdateFactory.newLatLng(CHU));
Map.addMarker(new MarkerOptions().position(Musée).title("Musée"));
Map.moveCamera(CameraUpdateFactory.newLatLng(Musée));
Map.addMarker(new MarkerOptions().position(Elkhroub).title("Elkhroub"));
Map.moveCamera(CameraUpdateFactory.newLatLng(Elkhroub));
Map.addMarker(new MarkerOptions().position(université_2).title("université_2"));
Map.moveCamera(CameraUpdateFactory.newLatLng(université_2));
Map.addMarker(new MarkerOptions().position(Centre_Culturel).title("Centre_Culturel"));
Map.moveCamera(CameraUpdateFactory.newLatLng(Centre_Culturel));
Map.addMarker(new MarkerOptions().position(université_3).title("université_3"));
Map.moveCamera(CameraUpdateFactory.newLatLng(université_3));
Map.addMarker(new MarkerOptions().position(Cité_Bekira).title("Cité_Bekira"));
Map.moveCamera(CameraUpdateFactory.newLatLng(Cité_Bekira));
Map.addMarker(new MarkerOptions().position(Ville_Zighoud).title("Ville_Zighoud"));
Map.moveCamera(CameraUpdateFactory.newLatLng(Ville_Zighoud));
Map.addMarker(new MarkerOptions().position(Aéroport).title("Aéroport"));
Map.moveCamera(CameraUpdateFactory.newLatLng(Aéroport));
// PolylineOptions options = new PolylineOptions().width(5).color(Color.BLUE).geodesic(true);
Map.addPolyline(new PolylineOptions().add(Elkhroub),
new LatLng(36.272298, 6.685093),
new LatLng(36.272298, 6.685093),
new LatLng(36.273396, 6.685345),
new LatLng(36.274170, 6.685844),
new LatLng(36.273820, 6.688907),
new LatLng(36.273794, 6.689588),
new LatLng(36.273844, 6.690644),
new LatLng(36.274631, 6.690612),
new LatLng(36.275609, 6.690612),
new LatLng(36.282026, 6.690376),
new LatLng(36.283306, 6.689710),
new LatLng(36.288210, 6.687017),
new LatLng(36.291461, 6.685945),
new LatLng(36.293926, 6.684700),
new LatLng(36.297229, 6.684206),
new LatLng(36.297601, 6.683970),
new LatLng(36.297921, 6.683563),
new LatLng(36.298448, 6.682565),
new LatLng(36.298621, 6.682307),
new LatLng(36.304453, 6.677330),
new LatLng(36.307393, 6.677298),
new LatLng(36.308353, 6.676912),
new LatLng(36.308491, 6.676676),
new LatLng(36.308456, 6.676000),
new LatLng(36.308796, 6.675584),
new LatLng(36.313223, 6.673428),
new LatLng(36.317908, 6.671733),
new LatLng(36.319784, 6.670788),
new LatLng(36.320510, 6.669909),
new LatLng(36.320744, 6.669512),
new LatLng(36.321133, 6.668353),
new LatLng(36.321746, 6.665746),
new LatLng(36.322058, 6.664920),
new LatLng(36.322645, 6.663858),
new LatLng(36.323544, 6.662806),
new LatLng(36.323709, 6.662677),
new LatLng(36.328290, 6.656187),
new LatLng(36.329509, 6.654760),
new LatLng(36.335507, 6.651959),
new LatLng(36.337391, 6.650286),
new LatLng(36.341358, 6.645576),
new LatLng(36.343778, 6.643001),
new LatLng(36.344210, 6.642593),
new LatLng(36.344875, 6.642260),
new LatLng(36.345350, 6.642185),
new LatLng(36.345886, 6.642271),
new LatLng(36.346889, 6.642443),
new LatLng(36.347364, 6.642325),
new LatLng(36.348064, 6.641595),
new LatLng(36.348980, 6.639289),
new LatLng(36.349135, 6.634815),
new LatLng(36.348962, 6.633720),
new LatLng(36.348721, 6.632347),
new LatLng(36.349369, 6.629590),
new LatLng(36.350155, 6.627551),
new LatLng(36.351365, 6.626232),
new LatLng(36.351572, 6.625481),
new LatLng(36.350699, 6.619548),
new LatLng(36.349541, 6.617413),
new LatLng(36.349274, 6.612896),
new LatLng(36.349032, 6.611179),
new LatLng(36.348193, 6.609849),
new LatLng(36.342317, 6.605911),
new LatLng(36.341522, 6.605149),
new LatLng(36.339223, 6.601266),
new LatLng(36.337235, 6.596620),
new LatLng(36.336976, 6.595215),
new LatLng(36.336985, 6.591674),
new LatLng(36.336847, 6.591213),
new LatLng(36.335680, 6.589593),
new LatLng(36.330312, 6.585054),
new LatLng(36.326972, 6.581404),
new LatLng(36.327196, 6.580686),
new LatLng(36.327118, 6.579827),
new LatLng(36.327300, 6.579033),
new LatLng(36.328484, 6.578905),
new LatLng(36.329158, 6.579259),
new LatLng(36.331070, 6.579613),
new LatLng(36.331111, 6.577973),
new LatLng(36.330718, 6.577907),
new LatLng(36.330839, 6.576931),
// new PolylineOptions().width(5).color(Color.BLUE).geodesic(true),
// new PolylineOptions().add(Cité_Boussouf).width(5).color(Color.BLUE).geodesic(true);
(Cité_Boussouf).width(5).color(Color.BLUE));
//Polyline polyline = Map.addPolyline(options);
}
}