Toggle navigation
Toggle navigation
This project
Loading...
Sign in
open-source
/
warply_android_sdk_maven_plugin
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Panagiotis Triantafyllou
2024-06-19 17:56:03 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a81b797cd21181b96f57ea851965d251d53c5593
a81b797c
1 parent
e26693b7
custom map pins
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
464 additions
and
43 deletions
warply_android_sdk/build.gradle
warply_android_sdk/src/main/java/ly/warp/sdk/activities/ShopsActivity.java
warply_android_sdk/src/main/java/ly/warp/sdk/activities/ShopsHuaweiActivity.java
warply_android_sdk/src/main/res/drawable-xhdpi/map_pin.png
warply_android_sdk/build.gradle
View file @
a81b797
...
...
@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
ext
{
PUBLISH_GROUP_ID
=
'ly.warp'
PUBLISH_VERSION
=
'4.5.5.4r2
8
'
PUBLISH_VERSION
=
'4.5.5.4r2
9
'
PUBLISH_ARTIFACT_ID
=
'warply-android-sdk'
}
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/activities/ShopsActivity.java
View file @
a81b797
...
...
@@ -5,6 +5,9 @@ import android.content.ActivityNotFoundException;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.pm.PackageManager
;
import
android.graphics.Bitmap
;
import
android.graphics.Canvas
;
import
android.graphics.drawable.Drawable
;
import
android.net.Uri
;
import
android.os.Bundle
;
import
android.text.TextUtils
;
...
...
@@ -15,6 +18,7 @@ import android.widget.LinearLayout;
import
android.widget.TextView
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
androidx.appcompat.app.AlertDialog
;
import
androidx.core.app.ActivityCompat
;
import
androidx.core.content.ContextCompat
;
...
...
@@ -22,11 +26,14 @@ import androidx.fragment.app.FragmentActivity;
import
com.bumptech.glide.Glide
;
import
com.bumptech.glide.load.engine.DiskCacheStrategy
;
import
com.bumptech.glide.request.target.CustomTarget
;
import
com.bumptech.glide.request.transition.Transition
;
import
com.google.android.gms.maps.CameraUpdate
;
import
com.google.android.gms.maps.CameraUpdateFactory
;
import
com.google.android.gms.maps.GoogleMap
;
import
com.google.android.gms.maps.OnMapReadyCallback
;
import
com.google.android.gms.maps.SupportMapFragment
;
import
com.google.android.gms.maps.model.BitmapDescriptorFactory
;
import
com.google.android.gms.maps.model.LatLng
;
import
com.google.android.gms.maps.model.Marker
;
import
com.google.android.gms.maps.model.MarkerOptions
;
...
...
@@ -312,21 +319,11 @@ public class ShopsActivity extends FragmentActivity implements View.OnClickListe
mMerchantList
.
clear
();
mMerchantList
.
addAll
(
result
);
// if (mClusterManager != null) {
// mMap.clear();
// mClusterManager.clearItems();
// if (result != null) {
// mClusterManager.addItems(result);
// }
// mClusterManager.cluster();
// }
int
nonNullCoords
=
0
;
for
(
Merchant
merchCoords
:
result
)
{
if
(
merchCoords
.
getLatitude
()
!=
0.0
&&
merchCoords
.
getLongitude
()
!=
0.0
)
{
nonNullCoords
++;
}
else
{
// mMerchantParent = merchCoords;
mMerchantParentList
.
add
(
merchCoords
);
}
}
...
...
@@ -337,12 +334,74 @@ public class ShopsActivity extends FragmentActivity implements View.OnClickListe
}
for
(
Merchant
merch
:
result
)
{
if
(!
TextUtils
.
isEmpty
(
merch
.
getImgPreview
()))
{
Glide
.
with
(
ShopsActivity
.
this
)
.
asBitmap
()
.
load
(
R
.
drawable
.
map_pin
)
.
into
(
new
CustomTarget
<
Bitmap
>()
{
@Override
public
void
onResourceReady
(
@NonNull
Bitmap
staticImage
,
@Nullable
Transition
<?
super
Bitmap
>
transition
)
{
Glide
.
with
(
ShopsActivity
.
this
)
.
asBitmap
()
.
load
(
merch
.
getImgPreview
())
.
into
(
new
CustomTarget
<
Bitmap
>()
{
@Override
public
void
onResourceReady
(
@NonNull
Bitmap
poiImage
,
@Nullable
Transition
<?
super
Bitmap
>
transition
)
{
Bitmap
combinedBitmap
=
overlayBitmaps
(
staticImage
,
poiImage
,
48
,
48
,
0.2f
);
mMap
.
addMarker
(
new
MarkerOptions
()
.
position
(
new
LatLng
(
merch
.
getLatitude
(),
merch
.
getLongitude
()))
.
icon
(
BitmapDescriptorFactory
.
fromBitmap
(
combinedBitmap
))
.
anchor
(
0.5f
,
0.5f
)
.
title
(
merch
.
getTitle
())
.
snippet
(
merch
.
getUuid
()));
}
@Override
public
void
onLoadCleared
(
@Nullable
Drawable
placeholder
)
{
mMap
.
addMarker
(
new
MarkerOptions
()
.
position
(
new
LatLng
(
merch
.
getLatitude
(),
merch
.
getLongitude
()))
.
anchor
(
0.5f
,
0.5f
)
.
title
(
merch
.
getTitle
())
.
snippet
(
merch
.
getUuid
()));
}
@Override
public
void
onLoadFailed
(
@Nullable
Drawable
errorDrawable
)
{
mMap
.
addMarker
(
new
MarkerOptions
()
.
position
(
new
LatLng
(
merch
.
getLatitude
(),
merch
.
getLongitude
()))
.
anchor
(
0.5f
,
0.5f
)
.
title
(
merch
.
getTitle
())
.
snippet
(
merch
.
getUuid
()));
}
});
}
@Override
public
void
onLoadCleared
(
@Nullable
Drawable
placeholder
)
{
mMap
.
addMarker
(
new
MarkerOptions
()
.
position
(
new
LatLng
(
merch
.
getLatitude
(),
merch
.
getLongitude
()))
.
anchor
(
0.5f
,
0.5f
)
.
title
(
merch
.
getTitle
())
.
snippet
(
merch
.
getUuid
()));
}
@Override
public
void
onLoadFailed
(
@Nullable
Drawable
errorDrawable
)
{
mMap
.
addMarker
(
new
MarkerOptions
()
.
position
(
new
LatLng
(
merch
.
getLatitude
(),
merch
.
getLongitude
()))
.
anchor
(
0.5f
,
0.5f
)
.
title
(
merch
.
getTitle
())
.
snippet
(
merch
.
getUuid
()));
}
});
}
else
{
mMap
.
addMarker
(
new
MarkerOptions
()
.
position
(
new
LatLng
(
merch
.
getLatitude
(),
merch
.
getLongitude
()))
.
anchor
(
0.5f
,
0.5f
)
.
title
(
merch
.
getTitle
())
.
snippet
(
merch
.
getUuid
()));
}
}
}
@Override
...
...
@@ -362,21 +421,11 @@ public class ShopsActivity extends FragmentActivity implements View.OnClickListe
mMerchantList
.
clear
();
mMerchantList
.
addAll
(
result
);
// if (mClusterManager != null) {
// mMap.clear();
// mClusterManager.clearItems();
// if (result != null) {
// mClusterManager.addItems(result);
// }
// mClusterManager.cluster();
// }
int
nonNullCoords
=
0
;
for
(
Merchant
merchCoords
:
result
)
{
if
(
merchCoords
.
getLatitude
()
!=
0.0
&&
merchCoords
.
getLongitude
()
!=
0.0
)
{
nonNullCoords
++;
}
else
{
// mMerchantParent = merchCoords;
mMerchantParentList
.
add
(
merchCoords
);
}
}
...
...
@@ -386,25 +435,147 @@ public class ShopsActivity extends FragmentActivity implements View.OnClickListe
return
;
}
// if (mMerchantParent != null) {
if
(
mMerchantParentList
!=
null
&&
mMerchantParentList
.
size
()
>
0
)
{
for
(
Merchant
parentMerch
:
mMerchantParentList
)
{
for
(
Merchant
merch
:
result
)
{
if
(
parentMerch
.
getUuid
().
equals
(
merch
.
getParent
()))
{
merch
.
setImg_preview
(
parentMerch
.
getImgPreview
());
if
(
merch
.
getLatitude
()
!=
0.0
&&
merch
.
getLongitude
()
!=
0.0
)
{
if
(!
TextUtils
.
isEmpty
(
merch
.
getImgPreview
()))
{
Glide
.
with
(
ShopsActivity
.
this
)
.
asBitmap
()
.
load
(
R
.
drawable
.
map_pin
)
.
into
(
new
CustomTarget
<
Bitmap
>()
{
@Override
public
void
onResourceReady
(
@NonNull
Bitmap
staticImage
,
@Nullable
Transition
<?
super
Bitmap
>
transition
)
{
Glide
.
with
(
ShopsActivity
.
this
)
.
asBitmap
()
.
load
(
merch
.
getImgPreview
())
.
into
(
new
CustomTarget
<
Bitmap
>()
{
@Override
public
void
onResourceReady
(
@NonNull
Bitmap
poiImage
,
@Nullable
Transition
<?
super
Bitmap
>
transition
)
{
Bitmap
combinedBitmap
=
overlayBitmaps
(
staticImage
,
poiImage
,
48
,
48
,
0.2f
);
mMap
.
addMarker
(
new
MarkerOptions
()
.
position
(
new
LatLng
(
merch
.
getLatitude
(),
merch
.
getLongitude
()))
.
icon
(
BitmapDescriptorFactory
.
fromBitmap
(
combinedBitmap
))
.
anchor
(
0.5f
,
0.5f
)
.
title
(
merch
.
getTitle
())
.
snippet
(
merch
.
getUuid
()));
}
@Override
public
void
onLoadCleared
(
@Nullable
Drawable
placeholder
)
{
mMap
.
addMarker
(
new
MarkerOptions
()
.
position
(
new
LatLng
(
merch
.
getLatitude
(),
merch
.
getLongitude
()))
.
anchor
(
0.5f
,
0.5f
)
.
title
(
merch
.
getTitle
())
.
snippet
(
merch
.
getUuid
()));
}
@Override
public
void
onLoadFailed
(
@Nullable
Drawable
errorDrawable
)
{
mMap
.
addMarker
(
new
MarkerOptions
()
.
position
(
new
LatLng
(
merch
.
getLatitude
(),
merch
.
getLongitude
()))
.
anchor
(
0.5f
,
0.5f
)
.
title
(
merch
.
getTitle
())
.
snippet
(
merch
.
getUuid
()));
}
});
}
@Override
public
void
onLoadCleared
(
@Nullable
Drawable
placeholder
)
{
mMap
.
addMarker
(
new
MarkerOptions
()
.
position
(
new
LatLng
(
merch
.
getLatitude
(),
merch
.
getLongitude
()))
.
anchor
(
0.5f
,
0.5f
)
.
title
(
merch
.
getTitle
())
.
snippet
(
merch
.
getUuid
()));
}
@Override
public
void
onLoadFailed
(
@Nullable
Drawable
errorDrawable
)
{
mMap
.
addMarker
(
new
MarkerOptions
()
.
position
(
new
LatLng
(
merch
.
getLatitude
(),
merch
.
getLongitude
()))
.
anchor
(
0.5f
,
0.5f
)
.
title
(
merch
.
getTitle
())
.
snippet
(
merch
.
getUuid
()));
}
});
}
else
{
mMap
.
addMarker
(
new
MarkerOptions
()
.
position
(
new
LatLng
(
merch
.
getLatitude
(),
merch
.
getLongitude
()))
.
anchor
(
0.5f
,
0.5f
)
.
title
(
merch
.
getTitle
())
.
snippet
(
merch
.
getUuid
()));
}
}
}
}
}
}
else
{
for
(
Merchant
merch
:
result
)
{
if
(
merch
.
getLatitude
()
!=
0.0
&&
merch
.
getLongitude
()
!=
0.0
)
{
if
(!
TextUtils
.
isEmpty
(
merch
.
getImgPreview
()))
{
Glide
.
with
(
ShopsActivity
.
this
)
.
asBitmap
()
.
load
(
R
.
drawable
.
map_pin
)
.
into
(
new
CustomTarget
<
Bitmap
>()
{
@Override
public
void
onResourceReady
(
@NonNull
Bitmap
staticImage
,
@Nullable
Transition
<?
super
Bitmap
>
transition
)
{
Glide
.
with
(
ShopsActivity
.
this
)
.
asBitmap
()
.
load
(
merch
.
getImgPreview
())
.
into
(
new
CustomTarget
<
Bitmap
>()
{
@Override
public
void
onResourceReady
(
@NonNull
Bitmap
poiImage
,
@Nullable
Transition
<?
super
Bitmap
>
transition
)
{
Bitmap
combinedBitmap
=
overlayBitmaps
(
staticImage
,
poiImage
,
48
,
48
,
0.2f
);
mMap
.
addMarker
(
new
MarkerOptions
()
.
position
(
new
LatLng
(
merch
.
getLatitude
(),
merch
.
getLongitude
()))
.
icon
(
BitmapDescriptorFactory
.
fromBitmap
(
combinedBitmap
))
.
anchor
(
0.5f
,
0.5f
)
.
title
(
merch
.
getTitle
())
.
snippet
(
merch
.
getUuid
()));
}
@Override
public
void
onLoadCleared
(
@Nullable
Drawable
placeholder
)
{
mMap
.
addMarker
(
new
MarkerOptions
()
.
position
(
new
LatLng
(
merch
.
getLatitude
(),
merch
.
getLongitude
()))
.
anchor
(
0.5f
,
0.5f
)
.
title
(
merch
.
getTitle
())
.
snippet
(
merch
.
getUuid
()));
}
@Override
public
void
onLoadFailed
(
@Nullable
Drawable
errorDrawable
)
{
mMap
.
addMarker
(
new
MarkerOptions
()
.
position
(
new
LatLng
(
merch
.
getLatitude
(),
merch
.
getLongitude
()))
.
anchor
(
0.5f
,
0.5f
)
.
title
(
merch
.
getTitle
())
.
snippet
(
merch
.
getUuid
()));
}
});
}
@Override
public
void
onLoadCleared
(
@Nullable
Drawable
placeholder
)
{
mMap
.
addMarker
(
new
MarkerOptions
()
.
position
(
new
LatLng
(
merch
.
getLatitude
(),
merch
.
getLongitude
()))
.
anchor
(
0.5f
,
0.5f
)
.
title
(
merch
.
getTitle
())
.
snippet
(
merch
.
getUuid
()));
}
@Override
public
void
onLoadFailed
(
@Nullable
Drawable
errorDrawable
)
{
mMap
.
addMarker
(
new
MarkerOptions
()
.
position
(
new
LatLng
(
merch
.
getLatitude
(),
merch
.
getLongitude
()))
.
anchor
(
0.5f
,
0.5f
)
.
title
(
merch
.
getTitle
())
.
snippet
(
merch
.
getUuid
()));
}
});
}
else
{
mMap
.
addMarker
(
new
MarkerOptions
()
.
position
(
new
LatLng
(
merch
.
getLatitude
(),
merch
.
getLongitude
()))
.
anchor
(
0.5f
,
0.5f
)
...
...
@@ -414,6 +585,7 @@ public class ShopsActivity extends FragmentActivity implements View.OnClickListe
}
}
}
}
@Override
public
void
onFailure
(
int
errorCode
)
{
...
...
@@ -421,6 +593,37 @@ public class ShopsActivity extends FragmentActivity implements View.OnClickListe
}
};
private
Bitmap
overlayBitmaps
(
Bitmap
staticImage
,
Bitmap
poiImage
,
int
poiImageWidth
,
int
poiImageHeight
,
float
scale
)
{
// Resize the POI image
Bitmap
resizedPoiImage
;
int
poiImageWidthScale
=
0
;
int
poiImageHeightScale
=
0
;
if
(
scale
==
0
)
resizedPoiImage
=
Bitmap
.
createScaledBitmap
(
poiImage
,
poiImageWidth
,
poiImageHeight
,
false
);
else
{
// Calculate the new dimensions for the POI image
poiImageWidthScale
=
(
int
)
(
poiImage
.
getWidth
()
*
scale
);
poiImageHeightScale
=
(
int
)
(
poiImage
.
getHeight
()
*
scale
);
resizedPoiImage
=
Bitmap
.
createScaledBitmap
(
poiImage
,
poiImageWidthScale
,
poiImageHeightScale
,
false
);
}
// Create a new bitmap with the same size as the static image
Bitmap
combinedBitmap
=
Bitmap
.
createBitmap
(
staticImage
.
getWidth
(),
staticImage
.
getHeight
(),
staticImage
.
getConfig
());
Canvas
canvas
=
new
Canvas
(
combinedBitmap
);
// Draw the static image on the canvas
canvas
.
drawBitmap
(
staticImage
,
0
,
0
,
null
);
// Calculate the position to center the resized POI image on the static image
int
left
=
(
staticImage
.
getWidth
()
-
resizedPoiImage
.
getWidth
())
/
2
;
int
top
=
(
staticImage
.
getHeight
()
-
resizedPoiImage
.
getHeight
())
/
3
;
// Draw the resized POI image on the canvas
canvas
.
drawBitmap
(
resizedPoiImage
,
left
,
top
,
null
);
return
combinedBitmap
;
}
// ===========================================================
// Inner and Anonymous Classes
// ===========================================================
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/activities/ShopsHuaweiActivity.java
View file @
a81b797
...
...
@@ -5,6 +5,9 @@ import android.content.ActivityNotFoundException;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.pm.PackageManager
;
import
android.graphics.Bitmap
;
import
android.graphics.Canvas
;
import
android.graphics.drawable.Drawable
;
import
android.net.Uri
;
import
android.os.Bundle
;
import
android.text.TextUtils
;
...
...
@@ -15,6 +18,7 @@ import android.widget.LinearLayout;
import
android.widget.TextView
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
androidx.appcompat.app.AlertDialog
;
import
androidx.core.app.ActivityCompat
;
import
androidx.core.content.ContextCompat
;
...
...
@@ -22,6 +26,8 @@ import androidx.fragment.app.FragmentActivity;
import
com.bumptech.glide.Glide
;
import
com.bumptech.glide.load.engine.DiskCacheStrategy
;
import
com.bumptech.glide.request.target.CustomTarget
;
import
com.bumptech.glide.request.transition.Transition
;
import
com.google.android.material.bottomsheet.BottomSheetDialog
;
import
com.huawei.hms.maps.CameraUpdate
;
import
com.huawei.hms.maps.CameraUpdateFactory
;
...
...
@@ -29,6 +35,7 @@ import com.huawei.hms.maps.HuaweiMap;
import
com.huawei.hms.maps.MapsInitializer
;
import
com.huawei.hms.maps.OnMapReadyCallback
;
import
com.huawei.hms.maps.SupportMapFragment
;
import
com.huawei.hms.maps.model.BitmapDescriptorFactory
;
import
com.huawei.hms.maps.model.LatLng
;
import
com.huawei.hms.maps.model.Marker
;
import
com.huawei.hms.maps.model.MarkerOptions
;
...
...
@@ -329,21 +336,11 @@ public class ShopsHuaweiActivity extends FragmentActivity implements View.OnClic
mMerchantList
.
clear
();
mMerchantList
.
addAll
(
result
);
// if (mClusterManager != null) {
// mMap.clear();
// mClusterManager.clearItems();
// if (result != null) {
// mClusterManager.addItems(result);
// }
// mClusterManager.cluster();
// }
int
nonNullCoords
=
0
;
for
(
Merchant
merchCoords
:
result
)
{
if
(
merchCoords
.
getLatitude
()
!=
0.0
&&
merchCoords
.
getLongitude
()
!=
0.0
)
{
nonNullCoords
++;
}
else
{
// mMerchantParent = merchCoords;
mMerchantParentList
.
add
(
merchCoords
);
}
}
...
...
@@ -354,13 +351,80 @@ public class ShopsHuaweiActivity extends FragmentActivity implements View.OnClic
}
for
(
Merchant
merch
:
result
)
{
if
(!
TextUtils
.
isEmpty
(
merch
.
getImgPreview
()))
{
Glide
.
with
(
ShopsHuaweiActivity
.
this
)
.
asBitmap
()
.
load
(
R
.
drawable
.
map_pin
)
.
into
(
new
CustomTarget
<
Bitmap
>()
{
@Override
public
void
onResourceReady
(
@NonNull
Bitmap
staticImage
,
@Nullable
Transition
<?
super
Bitmap
>
transition
)
{
Glide
.
with
(
ShopsHuaweiActivity
.
this
)
.
asBitmap
()
.
load
(
merch
.
getImgPreview
())
.
into
(
new
CustomTarget
<
Bitmap
>()
{
@Override
public
void
onResourceReady
(
@NonNull
Bitmap
poiImage
,
@Nullable
Transition
<?
super
Bitmap
>
transition
)
{
Bitmap
combinedBitmap
=
overlayBitmaps
(
staticImage
,
poiImage
,
48
,
48
,
0.2f
);
mMap
.
addMarker
(
new
MarkerOptions
()
.
position
(
new
LatLng
(
merch
.
getLatitude
(),
merch
.
getLongitude
()))
.
icon
(
BitmapDescriptorFactory
.
fromBitmap
(
combinedBitmap
))
.
anchor
(
0.5f
,
0.5f
)
.
title
(
merch
.
getTitle
())
.
snippet
(
merch
.
getUuid
())
.
clusterable
(
true
));
}
@Override
public
void
onLoadCleared
(
@Nullable
Drawable
placeholder
)
{
mMap
.
addMarker
(
new
MarkerOptions
()
.
position
(
new
LatLng
(
merch
.
getLatitude
(),
merch
.
getLongitude
()))
.
anchor
(
0.5f
,
0.5f
)
.
title
(
merch
.
getTitle
())
.
snippet
(
merch
.
getUuid
())
.
clusterable
(
true
));
}
@Override
public
void
onLoadFailed
(
@Nullable
Drawable
errorDrawable
)
{
mMap
.
addMarker
(
new
MarkerOptions
()
.
position
(
new
LatLng
(
merch
.
getLatitude
(),
merch
.
getLongitude
()))
.
anchor
(
0.5f
,
0.5f
)
.
title
(
merch
.
getTitle
())
.
snippet
(
merch
.
getUuid
())
.
clusterable
(
true
));
}
});
}
@Override
public
void
onLoadCleared
(
@Nullable
Drawable
placeholder
)
{
mMap
.
addMarker
(
new
MarkerOptions
()
.
position
(
new
LatLng
(
merch
.
getLatitude
(),
merch
.
getLongitude
()))
.
anchor
(
0.5f
,
0.5f
)
.
title
(
merch
.
getTitle
())
.
snippet
(
merch
.
getUuid
())
.
clusterable
(
true
));
}
@Override
public
void
onLoadFailed
(
@Nullable
Drawable
errorDrawable
)
{
mMap
.
addMarker
(
new
MarkerOptions
()
.
position
(
new
LatLng
(
merch
.
getLatitude
(),
merch
.
getLongitude
()))
.
anchor
(
0.5f
,
0.5f
)
.
title
(
merch
.
getTitle
())
.
snippet
(
merch
.
getUuid
())
.
clusterable
(
true
));
}
});
}
else
{
mMap
.
addMarker
(
new
MarkerOptions
()
.
position
(
new
LatLng
(
merch
.
getLatitude
(),
merch
.
getLongitude
()))
.
anchor
(
0.5f
,
0.5f
)
.
title
(
merch
.
getTitle
())
.
snippet
(
merch
.
getUuid
())
.
clusterable
(
true
));
}
}
}
@Override
...
...
@@ -380,21 +444,11 @@ public class ShopsHuaweiActivity extends FragmentActivity implements View.OnClic
mMerchantList
.
clear
();
mMerchantList
.
addAll
(
result
);
// if (mClusterManager != null) {
// mMap.clear();
// mClusterManager.clearItems();
// if (result != null) {
// mClusterManager.addItems(result);
// }
// mClusterManager.cluster();
// }
int
nonNullCoords
=
0
;
for
(
Merchant
merchCoords
:
result
)
{
if
(
merchCoords
.
getLatitude
()
!=
0.0
&&
merchCoords
.
getLongitude
()
!=
0.0
)
{
nonNullCoords
++;
}
else
{
// mMerchantParent = merchCoords;
mMerchantParentList
.
add
(
merchCoords
);
}
}
...
...
@@ -404,13 +458,59 @@ public class ShopsHuaweiActivity extends FragmentActivity implements View.OnClic
return
;
}
// if (mMerchantParent != null) {
if
(
mMerchantParentList
!=
null
&&
mMerchantParentList
.
size
()
>
0
)
{
for
(
Merchant
parentMerch
:
mMerchantParentList
)
{
for
(
Merchant
merch
:
result
)
{
if
(
parentMerch
.
getUuid
().
equals
(
merch
.
getParent
()))
{
merch
.
setImg_preview
(
parentMerch
.
getImgPreview
());
if
(
merch
.
getLatitude
()
!=
0.0
&&
merch
.
getLongitude
()
!=
0.0
)
{
if
(!
TextUtils
.
isEmpty
(
merch
.
getImgPreview
()))
{
Glide
.
with
(
ShopsHuaweiActivity
.
this
)
.
asBitmap
()
.
load
(
R
.
drawable
.
map_pin
)
.
into
(
new
CustomTarget
<
Bitmap
>()
{
@Override
public
void
onResourceReady
(
@NonNull
Bitmap
staticImage
,
@Nullable
Transition
<?
super
Bitmap
>
transition
)
{
Glide
.
with
(
ShopsHuaweiActivity
.
this
)
.
asBitmap
()
.
load
(
merch
.
getImgPreview
())
.
into
(
new
CustomTarget
<
Bitmap
>()
{
@Override
public
void
onResourceReady
(
@NonNull
Bitmap
poiImage
,
@Nullable
Transition
<?
super
Bitmap
>
transition
)
{
Bitmap
combinedBitmap
=
overlayBitmaps
(
staticImage
,
poiImage
,
48
,
48
,
0.2f
);
mMap
.
addMarker
(
new
MarkerOptions
()
.
position
(
new
LatLng
(
merch
.
getLatitude
(),
merch
.
getLongitude
()))
.
icon
(
BitmapDescriptorFactory
.
fromBitmap
(
combinedBitmap
))
.
anchor
(
0.5f
,
0.5f
)
.
title
(
merch
.
getTitle
())
.
snippet
(
merch
.
getUuid
())
.
clusterable
(
true
));
}
@Override
public
void
onLoadCleared
(
@Nullable
Drawable
placeholder
)
{
mMap
.
addMarker
(
new
MarkerOptions
()
.
position
(
new
LatLng
(
merch
.
getLatitude
(),
merch
.
getLongitude
()))
.
anchor
(
0.5f
,
0.5f
)
.
title
(
merch
.
getTitle
())
.
snippet
(
merch
.
getUuid
())
.
clusterable
(
true
));
}
@Override
public
void
onLoadFailed
(
@Nullable
Drawable
errorDrawable
)
{
mMap
.
addMarker
(
new
MarkerOptions
()
.
position
(
new
LatLng
(
merch
.
getLatitude
(),
merch
.
getLongitude
()))
.
anchor
(
0.5f
,
0.5f
)
.
title
(
merch
.
getTitle
())
.
snippet
(
merch
.
getUuid
())
.
clusterable
(
true
));
}
});
}
@Override
public
void
onLoadCleared
(
@Nullable
Drawable
placeholder
)
{
mMap
.
addMarker
(
new
MarkerOptions
()
.
position
(
new
LatLng
(
merch
.
getLatitude
(),
merch
.
getLongitude
()))
.
anchor
(
0.5f
,
0.5f
)
...
...
@@ -418,19 +518,106 @@ public class ShopsHuaweiActivity extends FragmentActivity implements View.OnClic
.
snippet
(
merch
.
getUuid
())
.
clusterable
(
true
));
}
@Override
public
void
onLoadFailed
(
@Nullable
Drawable
errorDrawable
)
{
mMap
.
addMarker
(
new
MarkerOptions
()
.
position
(
new
LatLng
(
merch
.
getLatitude
(),
merch
.
getLongitude
()))
.
anchor
(
0.5f
,
0.5f
)
.
title
(
merch
.
getTitle
())
.
snippet
(
merch
.
getUuid
())
.
clusterable
(
true
));
}
});
}
else
{
mMap
.
addMarker
(
new
MarkerOptions
()
.
position
(
new
LatLng
(
merch
.
getLatitude
(),
merch
.
getLongitude
()))
.
anchor
(
0.5f
,
0.5f
)
.
title
(
merch
.
getTitle
())
.
snippet
(
merch
.
getUuid
())
.
clusterable
(
true
));
}
}
}
}
}
}
else
{
for
(
Merchant
merch
:
result
)
{
if
(
merch
.
getLatitude
()
!=
0.0
&&
merch
.
getLongitude
()
!=
0.0
)
{
if
(!
TextUtils
.
isEmpty
(
merch
.
getImgPreview
()))
{
Glide
.
with
(
ShopsHuaweiActivity
.
this
)
.
asBitmap
()
.
load
(
R
.
drawable
.
map_pin
)
.
into
(
new
CustomTarget
<
Bitmap
>()
{
@Override
public
void
onResourceReady
(
@NonNull
Bitmap
staticImage
,
@Nullable
Transition
<?
super
Bitmap
>
transition
)
{
Glide
.
with
(
ShopsHuaweiActivity
.
this
)
.
asBitmap
()
.
load
(
merch
.
getImgPreview
())
.
into
(
new
CustomTarget
<
Bitmap
>()
{
@Override
public
void
onResourceReady
(
@NonNull
Bitmap
poiImage
,
@Nullable
Transition
<?
super
Bitmap
>
transition
)
{
Bitmap
combinedBitmap
=
overlayBitmaps
(
staticImage
,
poiImage
,
48
,
48
,
0.2f
);
mMap
.
addMarker
(
new
MarkerOptions
()
.
position
(
new
LatLng
(
merch
.
getLatitude
(),
merch
.
getLongitude
()))
.
icon
(
BitmapDescriptorFactory
.
fromBitmap
(
combinedBitmap
))
.
anchor
(
0.5f
,
0.5f
)
.
title
(
merch
.
getTitle
())
.
snippet
(
merch
.
getUuid
())
.
clusterable
(
true
));
}
@Override
public
void
onLoadCleared
(
@Nullable
Drawable
placeholder
)
{
mMap
.
addMarker
(
new
MarkerOptions
()
.
position
(
new
LatLng
(
merch
.
getLatitude
(),
merch
.
getLongitude
()))
.
anchor
(
0.5f
,
0.5f
)
.
title
(
merch
.
getTitle
())
.
snippet
(
merch
.
getUuid
())
.
clusterable
(
true
));
}
@Override
public
void
onLoadFailed
(
@Nullable
Drawable
errorDrawable
)
{
mMap
.
addMarker
(
new
MarkerOptions
()
.
position
(
new
LatLng
(
merch
.
getLatitude
(),
merch
.
getLongitude
()))
.
anchor
(
0.5f
,
0.5f
)
.
title
(
merch
.
getTitle
())
.
snippet
(
merch
.
getUuid
())
.
clusterable
(
true
));
}
});
}
@Override
public
void
onLoadCleared
(
@Nullable
Drawable
placeholder
)
{
mMap
.
addMarker
(
new
MarkerOptions
()
.
position
(
new
LatLng
(
merch
.
getLatitude
(),
merch
.
getLongitude
()))
.
anchor
(
0.5f
,
0.5f
)
.
title
(
merch
.
getTitle
())
.
snippet
(
merch
.
getUuid
())
.
clusterable
(
true
));
}
@Override
public
void
onLoadFailed
(
@Nullable
Drawable
errorDrawable
)
{
mMap
.
addMarker
(
new
MarkerOptions
()
.
position
(
new
LatLng
(
merch
.
getLatitude
(),
merch
.
getLongitude
()))
.
anchor
(
0.5f
,
0.5f
)
.
title
(
merch
.
getTitle
())
.
snippet
(
merch
.
getUuid
())
.
clusterable
(
true
));
}
});
}
else
{
mMap
.
addMarker
(
new
MarkerOptions
()
.
position
(
new
LatLng
(
merch
.
getLatitude
(),
merch
.
getLongitude
()))
.
anchor
(
0.5f
,
0.5f
)
.
title
(
merch
.
getTitle
())
.
snippet
(
merch
.
getUuid
())
.
clusterable
(
true
));
}
}
}
}
}
...
...
@@ -441,6 +628,37 @@ public class ShopsHuaweiActivity extends FragmentActivity implements View.OnClic
}
};
private
Bitmap
overlayBitmaps
(
Bitmap
staticImage
,
Bitmap
poiImage
,
int
poiImageWidth
,
int
poiImageHeight
,
float
scale
)
{
// Resize the POI image
Bitmap
resizedPoiImage
;
int
poiImageWidthScale
=
0
;
int
poiImageHeightScale
=
0
;
if
(
scale
==
0
)
resizedPoiImage
=
Bitmap
.
createScaledBitmap
(
poiImage
,
poiImageWidth
,
poiImageHeight
,
false
);
else
{
// Calculate the new dimensions for the POI image
poiImageWidthScale
=
(
int
)
(
poiImage
.
getWidth
()
*
scale
);
poiImageHeightScale
=
(
int
)
(
poiImage
.
getHeight
()
*
scale
);
resizedPoiImage
=
Bitmap
.
createScaledBitmap
(
poiImage
,
poiImageWidthScale
,
poiImageHeightScale
,
false
);
}
// Create a new bitmap with the same size as the static image
Bitmap
combinedBitmap
=
Bitmap
.
createBitmap
(
staticImage
.
getWidth
(),
staticImage
.
getHeight
(),
staticImage
.
getConfig
());
Canvas
canvas
=
new
Canvas
(
combinedBitmap
);
// Draw the static image on the canvas
canvas
.
drawBitmap
(
staticImage
,
0
,
0
,
null
);
// Calculate the position to center the resized POI image on the static image
int
left
=
(
staticImage
.
getWidth
()
-
resizedPoiImage
.
getWidth
())
/
2
;
int
top
=
(
staticImage
.
getHeight
()
-
resizedPoiImage
.
getHeight
())
/
3
;
// Draw the resized POI image on the canvas
canvas
.
drawBitmap
(
resizedPoiImage
,
left
,
top
,
null
);
return
combinedBitmap
;
}
// ===========================================================
// Inner and Anonymous Classes
// ===========================================================
...
...
warply_android_sdk/src/main/res/drawable-xhdpi/map_pin.png
0 → 100644
View file @
a81b797
4.01 KB
Please
register
or
login
to post a comment