neena
neena

Reputation: 581

How to show loading indicator inside a map marker? How to get the dragging marker location in map?

I want to add a loading indicator inside my google map marker. Marker is a cutomized imageenter image description here

I want to know the marker location when I drag this marker to any location in Map

Upvotes: 0

Views: 179

Answers (2)

IamKarim1992
IamKarim1992

Reputation: 646

Hi You could do something like this , which gets the position lat, lng position when the marker is dragged on the map ,

  function geocodePosition(pos) 
    {
       geocoder = new google.maps.Geocoder();
       geocoder.geocode
        ({
            latLng: pos
        }, 
            function(results, status) 
            {
                if (status == google.maps.GeocoderStatus.OK) 
                {
                   console.log(results[0].geometry.location.lat());
                   console.log(results[0].geometry.location.lng());
                } 
                else 
                {

                }
            }
        );
    }

    function initialize() {
      var mapOptions = {
        zoom: 14,
        center: new google.maps.LatLng(52.5498783, 13.425209099999961),
        mapTypeId: google.maps.MapTypeId.ROADMAP
      };
      map = new google.maps.Map(document.getElementById('map'), mapOptions);
      marker = new google.maps.Marker(
        {
          map:map,
          draggable:true,
          animation: google.maps.Animation.DROP,
          position: {lat: 52.5498783, lng: 13.425209099999961}
        });
       google.maps.event.addListener(map, 'dragend', function() { 
        var center= map.getCenter(); 
        var latitude=center.lat();
        var longitude=center.lng();
        marker.setMap(null);
         marker = new google.maps.Marker({
          map:map,
          draggable:true,
          animation: google.maps.Animation.DROP,
          position: {lat: latitude, lng: longitude}
        });
      });
      google.maps.event.addListener(marker, 'dragend', function(){
        geocodePosition(marker.getPosition());
    });
    }

Hope it helps , If u need more clarification . This is the javascript implementation.

Upvotes: 0

Poovizhirajan N
Poovizhirajan N

Reputation: 1263

Add this and get center point of map ...

    @Override
    public void onMapReady(final GoogleMap map) {

        map.setOnCameraChangeListener(new GoogleMap.OnCameraChangeListener() {
                @Override
                public void onCameraChange(CameraPosition cameraPosition) {
                       LatLng centerLatLng = cameraPosition.target;

                }
            });

}

For market design in Framelayout with ProgrssBar and ImageView add it to center of the map/screen

Upvotes: 2

Related Questions