8

I am working with the Here Map SDK and I need to show a blue icon with circle animation for current location like in image.

enter image description here

Can anyone tell me how to do it.

Right now I have code which sets the icon only which is blue dot. I don't know how to add circle animation to it.

Note that the mMap reference is a Map object from the Here Android SDK.

 mMap.getPositionIndicator().setVisible(true);
                    mMap.getPositionIndicator().setZIndex(0);
                    mMap.setZoomLevel(15);
                    mMap.getPositionIndicator().setAccuracyIndicatorVisible(true);
                    mMap.getPositionIndicator().setMarker(createImage(R.drawable.ic_location_dot));
Daniel Nugent
  • 43,104
  • 15
  • 109
  • 137
djk
  • 3,671
  • 9
  • 31
  • 40

8 Answers8

4

Try this one:

mMap.setMyLocationEnabled(true);

It enables or disables the my-location layer. While enabled and the location is available, the my-location layer continuously draws an indication of a user's current location and bearing, and displays UI controls that allow a user to interact with their location (for example, to enable or disable camera tracking of their location and bearing).

Much better if you place it under:

@Override
public void onMapReady(GoogleMap googleMap) {

}
icaneatclouds
  • 1,170
  • 9
  • 18
1

You can control the HERE Maps current location icon through com.here.android.mpa.mapping.PositionIndicator class.

Its instance is kept in com.here.android.mpa.mapping.MapView that might be wrapped in a fragment like com.here.android.mpa.mapping.SupportMapFragment.

Examples:

mapFragment.getPositionIndicator().setVisible(true)
mapView.getPositionIndicator().setAccuracyIndicatorVisible(true)
xsveda
  • 17,074
  • 2
  • 16
  • 16
0

For javascript you can use

map.addObject(new H.map.Circle(
// The central point of the circle
{lat:28.6071, lng:77.2127},
// The radius of the circle in meters
1000,
{
  style: {
    strokeColor: 'rgba(55, 85, 170, 0.6)', // Color of the perimeter
    lineWidth: 2,
    fillColor: 'rgba(0, 128, 0, 0.1)'  // Color of the circle
  }
}
));

There should be a similar implementation for android.

Joey Pinto
  • 1,735
  • 1
  • 18
  • 34
0

I have tested this code successfully and call addPulsatingEffect(Location userLocation) method with user's current location.

private Circle lastUserCircle;
private static final long PULSE_DURATION = 2000;
private static final float RADIUS = 200.0f;
private ValueAnimator lastPulseAnimator;

private void addPulsatingEffect(Location userLocation){

final LatLng userLatlng = new LatLng(userLocation.getLatitude(), userLocation.getLongitude());

if(lastPulseAnimator != null){
    lastPulseAnimator.cancel();
}

if(lastUserCircle != null) {
    lastUserCircle.setCenter(userLatlng);
}

lastPulseAnimator = valueAnimate(RADIUS, new ValueAnimator.AnimatorUpdateListener() {

    @Override
    public void onAnimationUpdate(ValueAnimator animation) {

        if(lastUserCircle != null)
            lastUserCircle.setRadius((Float) animation.getAnimatedValue());
        else {
            lastUserCircle = mMap.addCircle(new CircleOptions()
                    .center(userLatlng)
                    .radius((Float) animation.getAnimatedValue())
                    .strokeColor(Color.BLUE)
                    .strokeWidth(4.0f));
        }
    }
});
}

protected ValueAnimator valueAnimate(float radius, ValueAnimator.AnimatorUpdateListener updateListener){

ValueAnimator valueAnimator = ValueAnimator.ofFloat(0, radius);
valueAnimator.setDuration(PULSE_DURATION);
valueAnimator.addUpdateListener(updateListener);
valueAnimator.setRepeatCount(ValueAnimator.INFINITE);
valueAnimator.setRepeatMode(ValueAnimator.RESTART);

valueAnimator.start();
return valueAnimator;
}
Amila
  • 13
  • 6
  • I couldnt find many of the classes like Circle, LatLng, addCircle method for map etc. i am using here map and mMap is Map object for me. – djk Jul 12 '17 at 13:37
  • yes bro, "mMap" is a object of "com.google.android.gms.maps.GoogleMap", "Circle" is a object of "com.google.android.gms.maps.model.Circle", "LatLng" class is a object of "com.google.android.gms.maps.model.LatLng". Try with importing those classes. It will work definitely... – Amila Jul 13 '17 at 12:57
  • I am working with Here Map SDK. thats why this is not working for me – djk Jul 14 '17 at 18:12
0

For this use case, it is better to write your own position indicator.

Three things to do: 1: Register for PositioningManager callbacks which relay the updated position to your code. 2: Create a MapMarker with your desired image and add it to the map. 4: Create a MapCircle with the desired color and add it to the map. The radius for the circle should be set to the accuracy parameter of the Positioning Manager callback.

The logic to do this is to update the radius of the MapCircle, as well as update the GeoCoordinate of both the MapMarker and MapCircle whenever a new position is received from PositioningManager.

You can be fancy and add animations by using Timers and such to animate any accuracy changes.

David Leong
  • 1,662
  • 1
  • 11
  • 7
0

Enabling MyLocation Layer of Google Map

googleMap.setMyLocationEnabled(true);
Shreeya Chhatrala
  • 1,441
  • 18
  • 33
0
/* create a MarkerOptions */
MarkerOptions mOptions = new MarkerOptions();

/* create a MarkerInfoAdapter */
MarkerInfoAdapter infoAdapter = new MarkerInfoAdapter(MapsActivity.this.getLayoutInflater());

/* set MarkerInfoAdapter into your Map object */
MapFragment googleMap = FragmentManager.FindFragmentById<MapFragment> (Resource.Id.map);

/* get the GoogleMap object */
GoogleMap myMap = googleMap.getMapAsync(this);

/* set myMap type */
myMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);

/* set the MarkerInfoAdapter */
myMap.clear(); /* 
myMap.setInfoWindowAdapter(infoAdapter);


/* you must have your current location's LatLng  */
mOptions.position(currentLatLng); /* reach the position of the LatLng for that mark */

/* set the icon for your current location using BitmapDescriptorFactory */
mOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE));
myMap.addMarker(mOptions);

/* modify your marker icon to HUE_BLUE */                       mOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE));
Uddhav P. Gautam
  • 7,362
  • 3
  • 47
  • 64
0

I had the same problem as you and after two weeks of try all kind of options, this lines of code worked for me so yo can show the "blue icon"

m_map.setCenter(new GeoCoordinate(latitudeGPS, longitudeGPS, 0.0),Map.Animation.NONE);
                m_mapFragment.getPositionIndicator().setVisible(true);
                m_map.getPositionIndicator().setAccuracyIndicatorVisible(true);
                Log.d("initialize bolita", "" + 1.1 );
                PositioningManager.getInstance().start(PositioningManager.LocationMethod.GPS_NETWORK);m_map.addMapObject(m_positionIndicatorFixed);

Make sure you have requested all the permissions on your manifest.