Click here to Skip to main content
15,880,725 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi, I'm making an applcation in which i have implemented google map..m able to call current location of mine in my app..now i have following queries:

1)I want to add search option in my map..with that search option i can find places and things.

2)how will i navigate from my current location to the destination which i will select from my search result.

3) want to place marker to my current location.and want to autozoom to my current location

m not getting any idea:(.can anybody help me to solve this???

Here is my code:

Java
package com.example.navigate;

import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;

import android.os.Bundle;
import android.app.Activity;


public class MainActivity extends Activity {

   private GoogleMap googleMap;

   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);

      googleMap = ((MapFragment) getFragmentManager().
                          findFragmentById(R.id.map)).getMap();


      googleMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
      googleMap.setMyLocationEnabled(true);

   }

}
Posted
Updated 29-Oct-14 5:00am
v3

1 solution

Hi,
I think I can help for the question in number 3.
For number 1 and 2, I'm also having the same problem.
Luckily I found a Google Map Places API but couldn't find a Navigation one.
Places API: https://developers.google.com/places/documentation/[^]
So the above API is used on Servers(You'll read more).
For Question number 3:

Java
private void setUpMarker() {

GoogleMap gMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.gMap)).getMap();

LatLng NAIROBI = new LatLng(-1.283, 36.817);

Marker gMarker = gMap.addMarker(new MarkerOptions()
.position(NAIROBI)
.title("Kenya")
.snippet("Nairobi, Kenya!")
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE)));

}


Then call the above method where you wish.
If anything isn't straight, let me know, I'll explain.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900