Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
R
react-native-amap3d
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
放牛的园子
react-native-amap3d
Commits
e6e28a4b
Commit
e6e28a4b
authored
Jun 04, 2017
by
Qiu Xiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修正 InfoWindowPress 错误,并移除以链接形式设置 Marker 图标的方法
parent
4e467747
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
38 deletions
+15
-38
AMapMarker.java
...id/src/main/java/cn/qiuxiang/react/amap3d/AMapMarker.java
+0
-26
AMapMarkerManager.java
...main/java/cn/qiuxiang/react/amap3d/AMapMarkerManager.java
+1
-1
Marker.js
components/Marker.js
+4
-7
marker.js
example/src/marker.js
+10
-4
No files found.
android/src/main/java/cn/qiuxiang/react/amap3d/AMapMarker.java
View file @
e6e28a4b
...
...
@@ -59,28 +59,6 @@ public class AMapMarker extends ReactViewGroup {
private
boolean
infoWindowEnabled
=
true
;
private
BitmapDescriptor
bitmapDescriptor
;
private
RCTEventEmitter
eventEmitter
;
private
DataSubscriber
<
CloseableReference
<
CloseableImage
>>
dataSubscriber
=
new
BaseDataSubscriber
<
CloseableReference
<
CloseableImage
>>()
{
@Override
protected
void
onNewResultImpl
(
DataSource
<
CloseableReference
<
CloseableImage
>>
dataSource
)
{
CloseableReference
<
CloseableImage
>
ref
=
dataSource
.
getResult
();
if
(
ref
!=
null
)
{
try
{
bitmapDescriptor
=
BitmapDescriptorFactory
.
fromBitmap
(
((
CloseableStaticBitmap
)
ref
.
get
()).
getUnderlyingBitmap
());
if
(
marker
!=
null
)
{
marker
.
setIcon
(
bitmapDescriptor
);
}
}
finally
{
CloseableReference
.
closeSafely
(
ref
);
}
}
}
@Override
protected
void
onFailureImpl
(
DataSource
<
CloseableReference
<
CloseableImage
>>
dataSource
)
{
}
};
public
AMapMarker
(
ThemedReactContext
context
)
{
super
(
context
);
...
...
@@ -160,10 +138,6 @@ public class AMapMarker extends ReactViewGroup {
if
(
marker
!=
null
)
{
marker
.
setIcon
(
bitmapDescriptor
);
}
}
else
{
DataSource
<
CloseableReference
<
CloseableImage
>>
dataSource
=
Fresco
.
getImagePipeline
().
fetchDecodedImage
(
ImageRequest
.
fromUri
(
icon
),
this
);
dataSource
.
subscribe
(
dataSubscriber
,
CallerThreadExecutor
.
getInstance
());
}
}
...
...
android/src/main/java/cn/qiuxiang/react/amap3d/AMapMarkerManager.java
View file @
e6e28a4b
...
...
@@ -39,7 +39,7 @@ class AMapMarkerManager extends ViewGroupManager<AMapMarker> {
map
.
put
(
"onMarkerDragStart"
,
MapBuilder
.
of
(
"registrationName"
,
"onMarkerDragStart"
));
map
.
put
(
"onMarkerDrag"
,
MapBuilder
.
of
(
"registrationName"
,
"onMarkerDrag"
));
map
.
put
(
"onMarkerDragEnd"
,
MapBuilder
.
of
(
"registrationName"
,
"onMarkerDragEnd"
));
map
.
put
(
"onInfoWindowClick"
,
MapBuilder
.
of
(
"registrationName"
,
"on
CalloutPress
"
));
map
.
put
(
"onInfoWindowClick"
,
MapBuilder
.
of
(
"registrationName"
,
"on
InfoWindowClick
"
));
return
map
;
}
...
...
components/Marker.js
View file @
e6e28a4b
import
React
,
{
PropTypes
,
Component
}
from
'react'
import
{
requireNativeComponent
,
View
,
PixelRatio
}
from
'react-native'
import
resolveAssetSource
from
'react-native/Libraries/Image/resolveAssetSource'
import
{
CoordinatePropType
}
from
'./PropTypes'
import
InfoWindow
from
'./InfoWindow'
...
...
@@ -25,10 +24,11 @@ class Marker extends Component {
/**
* 自定义图标
* 可以是 uri 或者 require 引用的资源图片
*
* 可以是回调函数返回的自定义 View,需要注意的是,
* Root View 必须是 Overlay,且需设置 style width
*/
icon
:
PropTypes
.
oneOfType
([
PropTypes
.
number
,
PropTypes
.
string
,
PropTypes
.
func
,
]),
...
...
@@ -104,10 +104,7 @@ class Marker extends Component {
onMarkerDragStart
:
this
.
_handle
(
'onDragStart'
),
onMarkerDrag
:
this
.
_handle
(
'onDrag'
),
onMarkerDragEnd
:
this
.
_handle
(
'onDragEnd'
),
}
if
(
typeof
props
.
icon
===
'number'
)
{
props
.
icon
=
resolveAssetSource
(
this
.
props
.
icon
).
uri
onInfoWindowClick
:
this
.
_handle
(
'onInfoWindowPress'
),
}
let
customInfoWindow
=
null
...
...
example/src/marker.js
View file @
e6e28a4b
import
React
,
{
Component
}
from
'react'
import
{
StyleSheet
,
Alert
,
Text
}
from
'react-native'
import
{
StyleSheet
,
Alert
,
Text
,
Image
}
from
'react-native'
import
{
MapView
,
Marker
,
InfoWindow
,
Overlay
}
from
'react-native-amap3d'
export
default
class
MarkerExample
extends
Component
{
...
...
@@ -50,7 +50,11 @@ export default class MarkerExample extends Component {
<
/InfoWindow
>
<
/Marker
>
<
Marker
icon
=
{
require
(
'../images/marker.png'
)}
icon
=
{()
=>
<
Overlay
style
=
{{
width
:
40
,
height
:
40
}}
>
<
Image
style
=
{{
width
:
40
,
height
:
40
}}
source
=
{
require
(
'../images/marker.png'
)}
/
>
<
/Overlay
>
}
title
=
'自定义图片'
description
=
"Note the use of nativeOnly above. Sometimes you'll have some special properties that you need to expose for the native component, but don't actually want them as part of the API for the associated React component."
coordinate
=
{{
...
...
@@ -60,9 +64,11 @@ export default class MarkerExample extends Component {
/
>
<
Marker
title
=
'Custom View Marker'
icon
=
{()
=>
<
Overlay
style
=
{
styles
.
customMarker
}
>
icon
=
{()
=>
<
Overlay
style
=
{
styles
.
customMarker
}
>
<
Text
style
=
{
styles
.
markerText
}
>
{
this
.
state
.
time
.
toLocaleTimeString
()}
<
/Text
>
<
/Overlay>
}
<
/Overlay
>
}
coordinate
=
{{
latitude
:
39.706901
,
longitude
:
116.397972
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment