2

I am using "https://developers.google.com/maps/documentation/android-api/" Flat Markers code in my project. Map open and markers look but markers does not move.I do not understand what the problem.

Thank you for help me.

MapPane Java Class

import com.google.android.gms.maps.*;
import com.google.android.gms.maps.model.*;
import android.app.Activity;
import android.os.Bundle;

public class MapPane extends Activity implements OnMapReadyCallback {

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

    MapFragment mapFragment = (MapFragment) getFragmentManager()
            .findFragmentById(R.id.map_pane);
    mapFragment.getMapAsync(this);
}

@Override
public void onMapReady(GoogleMap map) {
    LatLng mapCenter = new LatLng(41.889, -87.622);

    map.moveCamera(CameraUpdateFactory.newLatLngZoom(mapCenter, 13));

    // Flat markers will rotate when the map is rotated,
    // and change perspective when the map is tilted.
    map.addMarker(new MarkerOptions()
            .icon(BitmapDescriptorFactory.fromResource(R.drawable.direction_arrow))
            .position(mapCenter)
            .flat(true)
            .rotation(245));

    CameraPosition cameraPosition = CameraPosition.builder()
            .target(mapCenter)
            .zoom(13)
            .bearing(90)
            .build();

    // Animate the change in camera view over 2 seconds
    map.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition),
            2000, null);
}
}

and

activity_map_pane

   <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.smsss.extundabitirmeprojesi3.MapPane">




   <fragment
        android:id="@+id/map_pane"
        android:name="com.google.android.gms.maps.MapFragment"
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"/>
</RelativeLayout>

emulator image

enter image description here

**

Why markers does not move?

**

sunay yildiz
  • 79
  • 2
  • 2
  • 13
  • you can;t move marker but if you want to do something like that than you must kept one static image in map fragment by central in parent and when you scroll map that time your maker is always in center but you can get that location latitude and longitude and call place api for get address name with lat,lng – Vishal Patoliya ツ May 18 '16 at 11:01
  • map.moveCamera(CameraUpdateFactory.newLatLngZoom( new LatLng(41.889, -87.622), 16)); that LatLng and map.addMarker(new MarkerOptions() .icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_login_lock)) .anchor(0.0f, 1.0f) // Anchors the marker on the bottom left .position(new LatLng(41.02342728,29.09385681))); this LatLng must be different ?? – sunay yildiz May 18 '16 at 11:11
  • you add your marker image in xml file thn after when you get lat,lng that time transfer camera on map to that marker – Vishal Patoliya ツ May 18 '16 at 11:14
  • You can try and take a look at this previous [SO question](http://stackoverflow.com/questions/27504606/how-to-implement-draggable-map-like-uber-android-update-with-change-location?lq=1) that may help you implement the `mMap.animateCamera(CameraUpdateFactory.newLatLng(latLng));` corectly. I hope this helps. Goodluck :) – Mr.Rebot May 19 '16 at 03:49
  • Hi Mr.Rebot LatLng latlng = new LatLng(40.7642108,29.9336313); mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)); ı have edited.but Nothing has changed – sunay yildiz May 19 '16 at 12:10

0 Answers0