Ir ao conteúdo
  • Cadastre-se

Traçar rotas entre marcadores já definidos, android maps


Posts recomendados

Boa tarde, estou elaborando um projeto para faculdade em android cujo objetivo é marcar os blocos da universiade e traçar rotas entre elas, mediante interação do usuário com os pontos, levando em conta as coordenadas dos marcadores(pontos) já criados, alguém pode me ajudar?

 

segue o código em java:

ps: coloquei javascript no code, prq n tem java

 

package com.example.felipeesteves.mapa_uniube;

import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

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.CameraPosition;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;

public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {

    private GoogleMap mMap;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_maps);
        // Obtain the SupportMapFragment and get notified when the map is ready to be used.
        SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
                .findFragmentById(R.id.map);
        mapFragment.getMapAsync(this);
    }



    /**
     * Manipulates the map once available.
     * This callback is triggered when the map is ready to be used.
     * This is where we can add markers or lines, add listeners or move the camera. In this case,
     * we just add a marker near Sydney, Australia.
     * If Google Play services is not installed on the device, the user will be prompted to install
     * it inside the SupportMapFragment. This method will only be triggered once the user has
     * installed Google Play services and returned to the app.
     */
    @Override
    public void onMapReady(GoogleMap googleMap) {
        mMap = googleMap;


        LatLng uniube = new LatLng(-19.760417, -47.964628);
        mMap.addMarker(new MarkerOptions().position(uniube).title("Marker in Uniube"));

        CameraPosition update = new CameraPosition(uniube, 15, 0, 0);
        mMap.animateCamera(CameraUpdateFactory.newCameraPosition(update), 5000, null);


        LatLng blocoS = new LatLng(-19.760056, -47.963713);
        mMap.addMarker(new MarkerOptions().position(blocoS).title("Bloco S"));


        LatLng LanchoneteBlocoS = new LatLng(-19.760292, -47.963406);
        mMap.addMarker(new MarkerOptions().position(LanchoneteBlocoS).title("Lanchonete bloco S"));


        LatLng blocoZ = new LatLng(-19.759263, -47.963083);
        mMap.addMarker(new MarkerOptions().position(blocoZ).title("Bloco Z"));

        LatLng blocoY = new LatLng(-19.759059, -47.962383);
        mMap.addMarker(new MarkerOptions().position(blocoY).title("Bloco Y"));


        LatLng blocoX = new LatLng(-19.758517, -47.962396);
        mMap.addMarker(new MarkerOptions().position(blocoX).title("Bloco X"));


        LatLng LanchoneteX = new LatLng(-19.758475, -47.962039);
        mMap.addMarker(new MarkerOptions().position(LanchoneteX).title("Lanchonete bloco X"));


        LatLng blocoH = new LatLng(-19.758391, -47.963670);
        mMap.addMarker(new MarkerOptions().position(blocoH).title("Bloco H"));

        LatLng Livraria = new LatLng(-19.757610, -47.963224);
        mMap.addMarker(new MarkerOptions().position(Livraria).title("Livraria Lemos & Cruz"));

        LatLng blocoI = new LatLng(-19.757262, -47.962935);
        mMap.addMarker(new MarkerOptions().position(blocoI).title("Bloco I"));


        LatLng LanchoneteCentral = new LatLng(-19.757398, -47.963630);
        mMap.addMarker(new MarkerOptions().position(LanchoneteCentral).title("Lanchonete Eliano"));

    }
}

 

Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novas respostas.

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...