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
adce6daa
Commit
adce6daa
authored
Jun 04, 2017
by
Qiu Xiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
分离 InfoWindowAdapter 代码
parent
903efe81
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
34 deletions
+46
-34
AMapInfoWindowAdapter.kt
...in/java/cn/qiuxiang/react/amap3d/AMapInfoWindowAdapter.kt
+44
-0
AMapView.kt
android/src/main/java/cn/qiuxiang/react/amap3d/AMapView.kt
+2
-34
No files found.
android/src/main/java/cn/qiuxiang/react/amap3d/AMapInfoWindowAdapter.kt
0 → 100644
View file @
adce6daa
package
cn.qiuxiang.react.amap3d
import
android.content.Context
import
android.graphics.Color
import
android.view.View
import
android.widget.LinearLayout
import
android.widget.TextView
import
com.amap.api.maps.AMap
import
com.amap.api.maps.model.Marker
class
AMapInfoWindowAdapter
(
val
context
:
Context
,
val
markers
:
HashMap
<
String
,
AMapMarker
>
)
:
AMap
.
InfoWindowAdapter
{
val
paddingTop
=
context
.
resources
.
displayMetrics
.
density
override
fun
getInfoWindow
(
marker
:
Marker
):
View
?
{
return
markers
[
marker
.
id
]
?.
infoWindow
}
override
fun
getInfoContents
(
marker
:
Marker
):
View
?
{
val
layout
=
LinearLayout
(
context
)
layout
.
orientation
=
LinearLayout
.
VERTICAL
val
titleView
=
TextView
(
context
)
titleView
.
text
=
marker
.
title
titleView
.
setTextColor
(
Color
.
parseColor
(
"#212121"
))
layout
.
addView
(
titleView
)
val
snippet
=
marker
.
snippet
if
(!
snippet
.
isEmpty
())
{
val
snippetView
=
TextView
(
context
)
snippetView
.
text
=
snippet
snippetView
.
setSingleLine
(
false
)
snippetView
.
maxEms
=
12
snippetView
.
setPadding
(
0
,
paddingTop
.
toInt
(),
0
,
0
)
snippetView
.
setTextColor
(
Color
.
parseColor
(
"#757575"
))
layout
.
addView
(
snippetView
)
}
return
layout
}
}
android/src/main/java/cn/qiuxiang/react/amap3d/AMapView.kt
View file @
adce6daa
package
cn.qiuxiang.react.amap3d
package
cn.qiuxiang.react.amap3d
import
android.graphics.Color
import
android.view.View
import
android.widget.LinearLayout
import
android.widget.TextView
import
com.amap.api.maps.AMap
import
com.amap.api.maps.AMap
import
com.amap.api.maps.MapView
import
com.amap.api.maps.MapView
import
com.amap.api.maps.model.Marker
import
com.amap.api.maps.model.Marker
...
@@ -79,39 +75,11 @@ class AMapView(context: ThemedReactContext) : MapView(context) {
...
@@ -79,39 +75,11 @@ class AMapView(context: ThemedReactContext) : MapView(context) {
markers
[
marker
.
id
]
?.
sendEvent
(
"onInfoWindowClick"
,
Arguments
.
createMap
())
markers
[
marker
.
id
]
?.
sendEvent
(
"onInfoWindowClick"
,
Arguments
.
createMap
())
}
}
map
.
setInfoWindowAdapter
(
object
:
AMap
.
InfoWindowAdapter
{
val
paddingTop
=
context
.
resources
.
displayMetrics
.
density
override
fun
getInfoWindow
(
marker
:
Marker
):
View
?
{
return
markers
[
marker
.
id
]
?.
infoWindow
}
override
fun
getInfoContents
(
marker
:
Marker
):
View
?
{
val
layout
=
LinearLayout
(
context
)
layout
.
orientation
=
LinearLayout
.
VERTICAL
val
titleView
=
TextView
(
context
)
titleView
.
text
=
marker
.
title
titleView
.
setTextColor
(
Color
.
parseColor
(
"#212121"
))
layout
.
addView
(
titleView
)
val
snippet
=
marker
.
snippet
if
(!
snippet
.
isEmpty
())
{
val
snippetView
=
TextView
(
context
)
snippetView
.
text
=
snippet
snippetView
.
setSingleLine
(
false
)
snippetView
.
maxEms
=
12
snippetView
.
setPadding
(
0
,
paddingTop
.
toInt
(),
0
,
0
)
snippetView
.
setTextColor
(
Color
.
parseColor
(
"#757575"
))
layout
.
addView
(
snippetView
)
}
return
layout
}
})
map
.
setOnPolylineClickListener
{
polyline
->
map
.
setOnPolylineClickListener
{
polyline
->
polylines
[
polyline
.
id
]
?.
sendEvent
(
"onPolylineClick"
,
Arguments
.
createMap
())
polylines
[
polyline
.
id
]
?.
sendEvent
(
"onPolylineClick"
,
Arguments
.
createMap
())
}
}
map
.
setInfoWindowAdapter
(
AMapInfoWindowAdapter
(
context
,
markers
))
}
}
fun
addMarker
(
marker
:
AMapMarker
)
{
fun
addMarker
(
marker
:
AMapMarker
)
{
...
...
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