Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scale marker's icons and add more icons on map zoom?

I'm working on mobile application where I'm using Android Map API v2. This app has global weather info and has lots of features related to Sea and Land weather parameters e.g Wind, Cloud, Rain, Pressure, Temperature, Wave, Swell.

As I mentioned; app has weather parameters, so to visualize these parameters on map I'm using Markers which seems working fine for for every parameters; I have set of icons for every parameters that I'm adding as Marker on the map.

My problem is that when I try to get deep zoom on map markers goes small instead scale and another issue is that, I'm plotting (Adding) markers on each 1 degree so when try zoom markers goes far then they appeared before on map.

  • Q 1. How do increase markers while zoom on map?
  • Q 2. Should I plot again?
  • Q 3. How do scale marker's icons on zoom?

This is what I'm doing to plot icons/markers on map:

    void CloudPlot()
    {
        var tempMarkers = new List<Marker>();
        int cloudItemCount = 0, i = 0;
        var data = GribReader.Instance.WeatherRequest.CloudRequest;
        cloudItemCount = data.Count;

        while (cloudItemCount > 0)
        {
            var cloudData = data[i];

            Bitmap cloudBitmap = RotateBitmap(-1, GetCloudIcon(cloudData.ValueData));
            Activity.RunOnUiThread(() =>
            {
                var cloudMarker = mwGoogleMap.AddMarker(new MarkerOptions()
                                            .SetPosition(new LatLng(cloudData.Latitude + 0.3, cloudData.Longitude + 0.4))
                                            .SetIcon(BitmapDescriptorFactory.FromBitmap(cloudBitmap))); //Cloud icon
                tempMarkers.Add(cloudMarker);
            });

            i++;
            cloudItemCount--;
            if (cloudItemCount == 0)
            {
                i = 0;
                ProgressCount--;
                //Interlocked.Decrement(ref _progressCount);
                if (VisibleParametrs.ContainsKey(MWParameters.CloudCover))
                    VisibleParametrs.Remove(MWParameters.CloudCover);

                VisibleParametrs.Add(MWParameters.CloudCover, tempMarkers);
            }
        }
        if (cloudItemCount == 0)
            ProgressCount--;
    }

Following to Rotate bitmap and reduce size:

    public Bitmap RotateBitmap(float angle, int windIcon)
    {
        Matrix matrix = new Matrix();
        if (angle > -1)
            matrix.PostRotate(angle);
        BitmapFactory.Options options = new BitmapFactory.Options();
        options.InSampleSize = 2;
        Bitmap source = BitmapFactory.DecodeResource(Resources, windIcon, options);
        return Bitmap.CreateBitmap(source, 0, 0, source.Width, source.Height, matrix, true);
    }

I'm getting following result after plotting cloud and wind icons on map (Without zoom):

With Zoom:

With Zoom

Thanks RIYAZ

like image 868
Mohammad Riyaz Avatar asked Nov 15 '25 16:11

Mohammad Riyaz


1 Answers

Try if clustering of markers helps https://developers.google.com/maps/documentation/android-api/utility/marker-clustering

Heatmaps look promising too. https://developers.google.com/maps/documentation/android-api/utility/heatmap

like image 96
Roshan Avatar answered Nov 17 '25 09:11

Roshan