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
4250b9fd
Commit
4250b9fd
authored
May 26, 2017
by
Qiu Xiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加 ViewManager 方法
parent
5c50845d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
100 additions
and
18 deletions
+100
-18
AMapView.java
android/src/main/java/com/qiuxiang/AMapView.java
+5
-16
AMapViewManager.java
android/src/main/java/com/qiuxiang/AMapViewManager.java
+95
-2
No files found.
android/src/main/java/com/qiuxiang/AMapView.java
View file @
4250b9fd
package
com
.
qiuxiang
;
import
android.content.Context
;
import
android.location.Location
;
import
com.amap.api.maps.AMap
;
import
com.amap.api.maps.MapView
;
import
com.amap.api.maps.UiSettings
;
public
class
AMapView
extends
MapView
{
private
final
AMap
amap
;
public
final
AMap
map
;
public
final
UiSettings
ui
;
public
AMapView
(
Context
context
)
{
super
(
context
);
super
.
onCreate
(
null
);
amap
=
this
.
getMap
();
}
public
AMap
getMap
()
{
return
amap
;
}
// public Location getMyLocation() {
// Location location = amap.getMyLocation();
// return location;
// }
public
void
setMyLocationEnabled
(
boolean
enabled
)
{
amap
.
setMyLocationEnabled
(
enabled
);
map
=
this
.
getMap
();
ui
=
map
.
getUiSettings
();
}
}
android/src/main/java/com/qiuxiang/AMapViewManager.java
View file @
4250b9fd
package
com
.
qiuxiang
;
import
com.amap.api.maps.AMap
;
import
com.amap.api.maps.CameraUpdateFactory
;
import
com.facebook.react.common.MapBuilder
;
import
com.facebook.react.uimanager.SimpleViewManager
;
import
com.facebook.react.uimanager.ThemedReactContext
;
import
com.facebook.react.uimanager.annotations.ReactProp
;
import
java.util.Map
;
class
AMapViewManager
extends
SimpleViewManager
<
AMapView
>
{
private
final
Map
<
String
,
Integer
>
MAP_TYPES
=
MapBuilder
.
of
(
"standard"
,
AMap
.
MAP_TYPE_NORMAL
,
"satellite"
,
AMap
.
MAP_TYPE_SATELLITE
,
"navigation"
,
AMap
.
MAP_TYPE_NAVI
,
"night"
,
AMap
.
MAP_TYPE_NIGHT
,
"bus"
,
AMap
.
MAP_TYPE_BUS
);
@Override
public
String
getName
()
{
return
"AMapView"
;
...
...
@@ -15,8 +28,88 @@ class AMapViewManager extends SimpleViewManager<AMapView> {
return
new
AMapView
(
reactContext
);
}
@ReactProp
(
name
=
"showUserLocation"
)
@ReactProp
(
name
=
"show
s
UserLocation"
)
public
void
setMyLocationEnabled
(
AMapView
view
,
boolean
enabled
)
{
view
.
getMap
().
setMyLocationEnabled
(
enabled
);
view
.
map
.
setMyLocationEnabled
(
enabled
);
}
@ReactProp
(
name
=
"showsIndoorMap"
)
public
void
showIndoorMap
(
AMapView
view
,
boolean
show
)
{
view
.
map
.
showIndoorMap
(
show
);
}
@ReactProp
(
name
=
"showsBuildings"
)
public
void
showBuildings
(
AMapView
view
,
boolean
show
)
{
view
.
map
.
showBuildings
(
show
);
}
@ReactProp
(
name
=
"showsMapText"
)
public
void
showMapText
(
AMapView
view
,
boolean
show
)
{
view
.
map
.
showMapText
(
show
);
}
@ReactProp
(
name
=
"showsCompass"
)
public
void
setCompassEnabled
(
AMapView
view
,
boolean
show
)
{
view
.
ui
.
setCompassEnabled
(
show
);
}
@ReactProp
(
name
=
"showZoomControls"
)
public
void
setZoomControlsEnabled
(
AMapView
view
,
boolean
enabled
)
{
view
.
ui
.
setZoomControlsEnabled
(
enabled
);
}
@ReactProp
(
name
=
"showScale"
)
public
void
setScaleControlsEnabled
(
AMapView
view
,
boolean
enabled
)
{
view
.
ui
.
setScaleControlsEnabled
(
enabled
);
}
@ReactProp
(
name
=
"showsMyLocationButton"
)
public
void
setMyLocationButtonEnabled
(
AMapView
view
,
boolean
enabled
)
{
view
.
ui
.
setMyLocationButtonEnabled
(
enabled
);
}
@ReactProp
(
name
=
"mapTextZIndex"
)
public
void
setMapTextZIndex
(
AMapView
view
,
int
zIndex
)
{
view
.
map
.
setMapTextZIndex
(
zIndex
);
}
@ReactProp
(
name
=
"showsTraffic"
)
public
void
setTrafficEnabled
(
AMapView
view
,
boolean
enabled
)
{
view
.
map
.
setTrafficEnabled
(
enabled
);
}
@ReactProp
(
name
=
"maxZoomLevel"
)
public
void
setMaxZoomLevel
(
AMapView
view
,
float
zoomLevel
)
{
view
.
map
.
setMaxZoomLevel
(
zoomLevel
);
}
@ReactProp
(
name
=
"minZoomLevel"
)
public
void
setMinZoomLevel
(
AMapView
view
,
float
zoomLevel
)
{
view
.
map
.
setMinZoomLevel
(
zoomLevel
);
}
@ReactProp
(
name
=
"zoomLevel"
)
public
void
setZoomLevel
(
AMapView
view
,
float
zoomLevel
)
{
view
.
map
.
animateCamera
(
CameraUpdateFactory
.
zoomTo
(
zoomLevel
));
}
@ReactProp
(
name
=
"mapType"
)
public
void
setMapType
(
AMapView
view
,
String
mapType
)
{
view
.
map
.
setMapType
(
MAP_TYPES
.
get
(
mapType
));
}
@ReactProp
(
name
=
"zoomEnabled"
)
public
void
setZoomGesturesEnabled
(
AMapView
view
,
boolean
enabled
)
{
view
.
ui
.
setZoomGesturesEnabled
(
enabled
);
}
@ReactProp
(
name
=
"scrollEnabled"
)
public
void
setScrollGesturesEnabled
(
AMapView
view
,
boolean
enabled
)
{
view
.
ui
.
setScrollGesturesEnabled
(
enabled
);
}
@ReactProp
(
name
=
"rotateEnabled"
)
public
void
setRotateGesturesEnabled
(
AMapView
view
,
boolean
enabled
)
{
view
.
ui
.
setRotateGesturesEnabled
(
enabled
);
}
}
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