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
f5e6b6a7
Commit
f5e6b6a7
authored
Jun 01, 2017
by
Qiu Xiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加 Marker Drag 事件接口
parent
ab572dfa
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
12 deletions
+55
-12
AMapMarkerManager.java
...main/java/cn/qiuxiang/react/amap3d/AMapMarkerManager.java
+3
-0
AMapView.java
android/src/main/java/cn/qiuxiang/react/amap3d/AMapView.java
+21
-0
Marker.js
components/Marker.js
+6
-0
marker.js
example/src/marker.js
+25
-12
No files found.
android/src/main/java/cn/qiuxiang/react/amap3d/AMapMarkerManager.java
View file @
f5e6b6a7
...
@@ -24,6 +24,9 @@ class AMapMarkerManager extends SimpleViewManager<AMapMarker> {
...
@@ -24,6 +24,9 @@ class AMapMarkerManager extends SimpleViewManager<AMapMarker> {
public
Map
<
String
,
Object
>
getExportedCustomDirectEventTypeConstants
()
{
public
Map
<
String
,
Object
>
getExportedCustomDirectEventTypeConstants
()
{
HashMap
<
String
,
Object
>
map
=
new
HashMap
<>();
HashMap
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"onMarkerClick"
,
MapBuilder
.
of
(
"registrationName"
,
"onMarkerClick"
));
map
.
put
(
"onMarkerClick"
,
MapBuilder
.
of
(
"registrationName"
,
"onMarkerClick"
));
map
.
put
(
"onMarkerDragStart"
,
MapBuilder
.
of
(
"registrationName"
,
"onMarkerDragStart"
));
map
.
put
(
"onMarkerDrag"
,
MapBuilder
.
of
(
"registrationName"
,
"onMarkerDrag"
));
map
.
put
(
"onMarkerDragEnd"
,
MapBuilder
.
of
(
"registrationName"
,
"onMarkerDragEnd"
));
return
map
;
return
map
;
}
}
...
...
android/src/main/java/cn/qiuxiang/react/amap3d/AMapView.java
View file @
f5e6b6a7
...
@@ -81,6 +81,27 @@ public class AMapView extends MapView {
...
@@ -81,6 +81,27 @@ public class AMapView extends MapView {
return
false
;
return
false
;
}
}
});
});
map
.
setOnMarkerDragListener
(
new
AMap
.
OnMarkerDragListener
()
{
@Override
public
void
onMarkerDragStart
(
Marker
marker
)
{
markers
.
get
(
marker
.
getId
()).
sendEvent
(
"onMarkerDragStart"
,
Arguments
.
createMap
());
}
@Override
public
void
onMarkerDrag
(
Marker
marker
)
{
markers
.
get
(
marker
.
getId
()).
sendEvent
(
"onMarkerDrag"
,
Arguments
.
createMap
());
}
@Override
public
void
onMarkerDragEnd
(
Marker
marker
)
{
LatLng
position
=
marker
.
getPosition
();
WritableMap
data
=
Arguments
.
createMap
();
data
.
putDouble
(
"latitude"
,
position
.
latitude
);
data
.
putDouble
(
"longitude"
,
position
.
longitude
);
markers
.
get
(
marker
.
getId
()).
sendEvent
(
"onMarkerDragEnd"
,
data
);
}
});
}
}
public
void
addMarker
(
AMapMarker
marker
)
{
public
void
addMarker
(
AMapMarker
marker
)
{
...
...
components/Marker.js
View file @
f5e6b6a7
...
@@ -52,6 +52,9 @@ class Marker extends Component {
...
@@ -52,6 +52,9 @@ class Marker extends Component {
zIndex
:
PropTypes
.
number
,
zIndex
:
PropTypes
.
number
,
onPress
:
React
.
PropTypes
.
func
,
onPress
:
React
.
PropTypes
.
func
,
onDragStart
:
React
.
PropTypes
.
func
,
onDrag
:
React
.
PropTypes
.
func
,
onDragEnd
:
React
.
PropTypes
.
func
,
}
}
_eventHandler
(
name
)
{
_eventHandler
(
name
)
{
...
@@ -66,6 +69,9 @@ class Marker extends Component {
...
@@ -66,6 +69,9 @@ class Marker extends Component {
const
props
=
{
const
props
=
{
...
this
.
props
,
...
this
.
props
,
onMarkerClick
:
this
.
_eventHandler
(
'onPress'
),
onMarkerClick
:
this
.
_eventHandler
(
'onPress'
),
onMarkerDragStart
:
this
.
_eventHandler
(
'onDragStart'
),
onMarkerDrag
:
this
.
_eventHandler
(
'onDrag'
),
onMarkerDragEnd
:
this
.
_eventHandler
(
'onDragEnd'
),
}
}
if
(
typeof
props
.
image
===
'number'
)
{
if
(
typeof
props
.
image
===
'number'
)
{
props
.
image
=
resolveAssetSource
(
this
.
props
.
image
).
uri
props
.
image
=
resolveAssetSource
(
this
.
props
.
image
).
uri
...
...
example/src/marker.js
View file @
f5e6b6a7
...
@@ -9,18 +9,31 @@ export default class MarkerComponent extends Component {
...
@@ -9,18 +9,31 @@ export default class MarkerComponent extends Component {
render
()
{
render
()
{
return
<
MapView
style
=
{
StyleSheet
.
absoluteFill
}
>
return
<
MapView
style
=
{
StyleSheet
.
absoluteFill
}
>
<
Marker
draggable
title
=
'这是一个可拖拽的 Marker'
coordinate
=
{{
<
Marker
latitude
:
39.806901
,
title
=
'一个可拖拽的 Marker'
longitude
:
116.397972
,
draggable
}}
/
>
onDragEnd
=
{({
nativeEvent
})
=>
console
.
log
(
nativeEvent
)}
<
Marker
image
=
'HUE_RED'
title
=
'其他颜色'
coordinate
=
{{
coordinate
=
{{
latitude
:
39.806901
,
latitude
:
39.806901
,
longitude
:
116.297972
,
longitude
:
116.397972
,
}}
/
>
}}
<
Marker
image
=
{
require
(
'../images/marker.png'
)}
title
=
'自定义图标'
coordinate
=
{{
/
>
latitude
:
39.906901
,
<
Marker
longitude
:
116.397972
,
image
=
'HUE_RED'
}}
/
>
title
=
'一个红色的 Marker'
coordinate
=
{{
latitude
:
39.806901
,
longitude
:
116.297972
,
}}
/
>
<
Marker
image
=
{
require
(
'../images/marker.png'
)}
title
=
'自定义图片'
coordinate
=
{{
latitude
:
39.906901
,
longitude
:
116.397972
,
}}
/
>
<
/MapView
>
<
/MapView
>
}
}
}
}
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