-
-
Notifications
You must be signed in to change notification settings - Fork 324
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
467 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...d/src/main/java/org/lovebing/reactnative/baidumap/uimanager/OverlayMarkerIconManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright (c) 2016-present, lovebing.net. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
package org.lovebing.reactnative.baidumap.uimanager; | ||
|
||
import androidx.annotation.NonNull; | ||
import com.facebook.react.uimanager.ThemedReactContext; | ||
import com.facebook.react.uimanager.ViewGroupManager; | ||
import org.lovebing.reactnative.baidumap.view.OverlayMarkerIcon; | ||
|
||
/** | ||
* @author lovebing | ||
* @date 2020-06-07 | ||
*/ | ||
public class OverlayMarkerIconManager extends ViewGroupManager<OverlayMarkerIcon> { | ||
|
||
@NonNull | ||
@Override | ||
public String getName() { | ||
return "BaiduMapOverlayMarkerIcon"; | ||
} | ||
|
||
@NonNull | ||
@Override | ||
protected OverlayMarkerIcon createViewInstance(@NonNull ThemedReactContext reactContext) { | ||
return new OverlayMarkerIcon(reactContext); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
android/src/main/java/org/lovebing/reactnative/baidumap/util/BitmapUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright (c) 2016-present, lovebing.net. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
package org.lovebing.reactnative.baidumap.util; | ||
|
||
import android.graphics.Bitmap; | ||
import android.graphics.Canvas; | ||
import android.graphics.Matrix; | ||
import android.view.View; | ||
|
||
import com.baidu.mapapi.map.BitmapDescriptor; | ||
import com.baidu.mapapi.map.BitmapDescriptorFactory; | ||
|
||
/** | ||
* @author lovebing | ||
* @date 2020-05-25 | ||
*/ | ||
public class BitmapUtil { | ||
|
||
public static BitmapDescriptor createBitmapDescriptor(View view) { | ||
return createBitmapDescriptor(view, 0, 0); | ||
} | ||
|
||
public static BitmapDescriptor createBitmapDescriptor(View view, int width, int height) { | ||
if (width > 0 && height > 0) { | ||
view.layout(0, 0, width, height); | ||
} else if (view.getMeasuredWidth() == 0 || view.getMeasuredHeight() == 0) { | ||
view.layout(0, 0, view.getMeasuredWidth() > 0 ? view.getMeasuredWidth() : 50, view.getMeasuredHeight() > 0 ? view.getMeasuredHeight() : 100); | ||
} | ||
view.buildDrawingCache(); | ||
BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(view.getDrawingCache()); | ||
view.destroyDrawingCache(); | ||
return bitmapDescriptor; | ||
} | ||
|
||
public static Bitmap resizeBitmap(Bitmap bitmap, int width, int height) { | ||
float scaleWidth = ((float) width) / bitmap.getWidth(); | ||
float scaleHeight = ((float) height) / bitmap.getHeight(); | ||
Matrix matrix = new Matrix(); | ||
matrix.postScale(scaleWidth, scaleHeight); | ||
return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
android/src/main/java/org/lovebing/reactnative/baidumap/view/OverlayMarkerIcon.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright (c) 2016-present, lovebing.net. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
package org.lovebing.reactnative.baidumap.view; | ||
|
||
import android.content.Context; | ||
import com.facebook.react.views.view.ReactViewGroup; | ||
|
||
/** | ||
* @author lovebing | ||
* @date 2020-06-07 | ||
*/ | ||
public class OverlayMarkerIcon extends ReactViewGroup { | ||
|
||
public OverlayMarkerIcon(Context context) { | ||
super(context); | ||
} | ||
} |
Oops, something went wrong.