如何在打开Google地图时重定向我当前的位置
这是我在SetUpMap()
中的代码@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = LayoutInflater.from(getApplicationContext())
.inflate(R.layout.rating_list, parent, false);
}
System.out.println("list size*******"+list.size());
HashMap<String, String> a = list.get(position);
System.out.println("Position of hash map----->"+position);
String name = a.get("provider_name");
System.out.println("name--------->"+name);
TextView tv = (TextView) convertView.findViewById(R.id.textView1);
tv.setText(name);
ratingbar = (RatingBar)convertView.findViewById(R.id.vendor_rating);
ratingbar.setOnRatingBarChangeListener(new OnRatingBarChangeListener() {
@Override
public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(), "Rating-->"+rating+"Position-->"+lv.getPositionForView(ratingBar), Toast.LENGTH_LONG).show();
System.out.println("Rating------>"+rating+"position----->"+lv.getPositionForView(ratingBar));
}
});
return convertView;
还有我如何更改标记?我只在我的位置得到那个蓝色圆圈。我想把它改成Pin
答案 0 :(得分:1)
<project name="NuggetaGameServer" basedir="." default="jar">
<target name="jar" description="jar">
<delete file="lib/myServer.jar" />
<mkdir dir="classes" />
<echo message="Compiling the java source files..." />
<javac destdir="classes" debug="on" failonerror="yes" includeantruntime="false">
<src path="src" />
</javac>
<jar destfile="lib/myServer.jar">
<zipfileset dir="classes/" />
</jar>
</target>
答案 1 :(得分:0)
在Map
准备就绪后立即获取用户的当前位置,您需要像这样设置相机的动画
Location location = this.mGoogleMap.getMyLocation();
if (location != null) {
LatLng target = new LatLng(location.getLatitude(), location.getLongitude());
CameraPosition position = this.mGoogleMap.getCameraPosition();
Builder builder = new CameraPosition.Builder();
builder.zoom(15);
builder.target(target);
this.mGoogleMap.animateCamera(CameraUpdateFactory.newCameraPosition(builder.build()));
}
因此,getMyLocation()
必须获取用户的位置。使用可以使用PROVIDERS
来获取位置。您还可以使用LocationListener
使用GoogleApiClient
收听位置信息。在发布此处之前,请阅读Getting the Last Known Location和Receiving Location Updates的文档。
要为您的位置提供自定义标记,可以使用名为addMarker
mGoogleMap.addMarker(new MarkerOptions()
.position(new LatLng(location.getLatitude(), location.getLogitude()))
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE)));
答案 2 :(得分:0)
您可以尝试使用此代码,我们可以通过NETWORK_PROVIDER获取谷歌地图中的位置。 NETWORK_PROVIDER从您的WIFI位置或您的网络提供商公司(IDEA,AIRTEL,VODAPHONE)中选择您的位置。
try {
if (googleMap == null) {
googleMap = ((MapFragment) getFragmentManager()
.findFragmentById(R.id.map)).getMap();
}
googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
googleMap.setMyLocationEnabled(true);
LocationManager location_manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
LocationListener listner = new getlatlngListner();
location_manager.requestLocationUpdates(
LocationManager.NETWORK_PROVIDER, 2000, 2000, listner);
location_manager
.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
} catch (Exception e) {
e.printStackTrace();
}
答案 3 :(得分:0)
private MarkerOptions mMarkerOptions = new MarkerOptions();
mMarkerOptions.visible(true);
mMarkerOptions.icon(BitmapDescriptorFactory.fromBitmap(Your bitmap));
mMap.setMyLocationEnabled(true);
mMap.getUiSettings().setMyLocationButtonEnabled(false);
mMap.setOnMyLocationChangeListener(new GoogleMap.OnMyLocationChangeListener() {
@Override
public void onMyLocationChange(Location location) {
LatLng mPos = new LatLng(location.getLatitude(),location.getLongitude());
mMarkerOptions.position(mPos);
mMap.addMarker(mMarkerOptions);
mMap.moveCamera(CameraUpdateFactory.newLatLng(mPos));
mMap.animateCamera(CameraUpdateFactory.zoomTo(17));
}
});