sharenowTech / AnyMaps

Easily switch between Google, Baidu and OSM maps
181 stars 39 forks source link

Adding map markers #7

Closed hardsoft closed 7 years ago

hardsoft commented 7 years ago

Is there and example of how to add a map marker.

I am wanting to show my current position and a destination position.

dmitry-zaitsev commented 7 years ago

Here is how you can do it.

First, initialize the MapsConfiguration.

MapsConfiguration.getInstance().initialize(this);

Second, add the marker as soon as the map is available.

mapView.getMapAsync(new OnMapReadyCallback() {
    @Override
    public void onMapReady(AnyMap anyMap) {
        anyMap.addMarker(
                new MarkerOptions()
                        .position(new LatLng(0, 0))
                        .icon(
                                BitmapDescriptorFactory.getInstance()
                                        .fromResource(R.drawable.marker)
                        )
        );
    }
});

I also updated the sample app, so that you can run it and try it.