无法在请求的地图图像上放置标记

时间:2016-03-09 09:55:26

标签: android google-maps

I want to have an image of a map of location whose latitude and longitude are known. So I use the code below-:

String src = "http://maps.google.com/maps/api/staticmap?center=" + latitude + "," + longitude + "&zoom=13&size=600x600&sensor=false";
Picasso.with(this).load(src).into(myEventMapImg);

很好,但我想在地图图片中的特定位置放置一个标记,该怎么做。这不是地图,是地图的图像。

1 个答案:

答案 0 :(得分:0)

将标记放置在特定位置的示例:

public class MainActivity extends FragmentActivity{
    private GoogleMap map;
    private LatLng source;
    private Marker sourceMarker, destiMarker;
    private ArrayList<LatLng> destiLatLong;
    private int count = 0;
    // private PolylineOptions lineOptions;
    private BeanRoute route;
    ArrayList<LatLng> points;
    private ProgressDialog pd;
    private ArrayList<MapsDirection> MapsDirectionList;

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

        if (map == null) {
            map = ((SupportMapFragment) getSupportFragmentManager()
                    .findFragmentById(R.id.map)).getMap();
            // map.setMyLocationEnabled(true);
        }
        MapsDirectionList = new ArrayList<MapsDirection>();
        source = new LatLng(new Double("22.3000"), new Double("70.7833"));
        sourceMarker = map.addMarker(new MarkerOptions().position(source).icon(
                BitmapDescriptorFactory
                        .defaultMarker(BitmapDescriptorFactory.HUE_BLUE)));
        destiLatLong = new ArrayList<LatLng>();


        destiLatLong.add(new LatLng(Double.parseDouble("21.7542"), Double
                .parseDouble("70.6222")));


        destiLatLong.add(new LatLng(Double.parseDouble("23.0300"), Double
                .parseDouble("72.5800")));


        destiLatLong.add(new LatLng(Double.parseDouble("21.1700"), Double
                .parseDouble("72.8300")));


        destiLatLong.add(new LatLng(Double.parseDouble("22.5667"), Double
                .parseDouble("88.3667")));


        destiLatLong.add(new LatLng(Double.parseDouble("28.6100"), Double
                .parseDouble("77.2300")));

        if (destiLatLong.size() > 0) {
            runOnUiThread(new Runnable() {

                @Override
                public void run() {
                    pd = Utils.showProgressDialog(MainActivity.this, "Wait",
                            "Getting Direction...");
                }
            });
            showDirection();
        }
    }