Android Question Create HueColor

D

Deleted member 103

Guest
Hi,

Who can translate this Java code into B4a?
I need only the function "getMarkerIcon". ;)

B4X:
Marker melbourne = mMap.addMarker(new MarkerOptions().position(MELBOURNE)
.icon(getMarkerIcon("#ff2299")));

// method definition
public BitmapDescriptor getMarkerIcon(String color) {
    float[] hsv = new float[3];
    Color.colorToHSV(Color.parseColor(color), hsv);
    return BitmapDescriptorFactory.defaultMarker(hsv[0]);
}

Thanks in advance.
 

Ohanian

Active Member
Licensed User
Longtime User
Hi,

B4X:
#If Java

import android.graphics.Color;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.BitmapDescriptor;

public BitmapDescriptor getMarkerIcon(String color) {
    float[] hsv = new float[3];
    Color.colorToHSV(Color.parseColor(color), hsv);
    return BitmapDescriptorFactory.defaultMarker(hsv[0]);
}

#End If

B4X:
MarkerOptions1.Icon(nativeMe.RunMethod("getMarkerIcon", Array As String("#ff2299")))
GoogleMapsExtras1.AddMarker(GoogleMap1, MarkerOptions1)
 
Last edited:
Upvote 0
D

Deleted member 103

Guest
Hi @Ohanian ,

Unfortunately I get this error message. :(

B4X:
Dim m1 As Marker = GoogleMap1.AddMarker3(Latitude, Longitude , i, getMarkerIcon(col))

Public Sub getMarkerIcon(Color As String) As Bitmap
    Dim NativeMe As JavaObject
    NativeMe.InitializeContext
    Return NativeMe.RunMethod("getMarkerIcon", Color)
End Sub

#If Java

import android.graphics.Color;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.BitmapDescriptor;

public BitmapDescriptor getMarkerIcon(String color) {
    float[] hsv = new float[3];
    Color.colorToHSV(Color.parseColor(color), hsv);
    return BitmapDescriptorFactory.defaultMarker(hsv[0]);
}

#End If
 

Attachments

  • marker.PNG
    marker.PNG
    20.4 KB · Views: 318
Upvote 0

Ohanian

Active Member
Licensed User
Longtime User
Hi,

B4X:
Public Sub getMarkerIcon(Color As String) As BitmapDescriptor
    Dim nativeMe As JavaObject
    nativeMe.InitializeContext
    Return nativeMe.RunMethod("getMarkerIcon", Array As String(Color))
End Sub
 
Upvote 0
Top