Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
app-FounderMap
Overview
Overview
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
常超
app-FounderMap
Commits
95981ce8
Commit
95981ce8
authored
Jul 12, 2020
by
Luosp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加地图绘制功能
parent
e914d4cf
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
586 additions
and
12 deletions
+586
-12
app/src/main/java/cn/com/founder/arcgisserver/MainActivity.java
+5
-3
arcgislib/proguard-rules.pro
+3
-0
arcgislib/src/main/java/cn/com/founder/arcgislib/ArcGisFounder.java
+43
-1
arcgislib/src/main/java/cn/com/founder/arcgislib/common/Variable.java
+3
-1
arcgislib/src/main/java/cn/com/founder/arcgislib/option/IOption.java
+6
-0
arcgislib/src/main/java/cn/com/founder/arcgislib/view/ArcGisClusterView.java
+2
-2
arcgislib/src/main/java/cn/com/founder/arcgislib/view/ArcGisDrawView.java
+251
-0
arcgislib/src/main/java/cn/com/founder/arcgislib/view/ArcGisLocationView.java
+5
-5
arcgislib/src/main/java/cn/com/founder/arcgislib/view/ArcGisMapView.java
+25
-0
arcgislib/src/main/java/cn/com/founder/arcgislib/widget/draw/DrawEntity.java
+65
-0
arcgislib/src/main/java/cn/com/founder/arcgislib/widget/draw/DrawLayer.java
+0
-0
arcgislib/src/main/java/cn/com/founder/arcgislib/widget/draw/DrawView.java
+162
-0
arcgislib/src/main/res/values/colors.xml
+3
-0
arcgislib/src/main/res/values/dimens.xml
+1
-0
arcgislib/src/main/res/values/strings.xml
+12
-0
No files found.
app/src/main/java/cn/com/founder/arcgisserver/MainActivity.java
View file @
95981ce8
...
...
@@ -29,6 +29,7 @@ public class MainActivity extends AppCompatActivity {
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_main
);
naviBt
=
findViewById
(
R
.
id
.
bt_navi
);
naviBt
.
setVisibility
(
View
.
GONE
);
ArcGisBaseView
arcGisBaseView
=
findViewById
(
R
.
id
.
main_arc_gis_base_view
);
//集成Activity
...
...
@@ -52,10 +53,11 @@ public class MainActivity extends AppCompatActivity {
.
setDefaultArcGisLocation
()
//设置默认定位
.
setDefaultArcGisZoom
()
//设置默认缩放
.
setDefaultArcGisCompass
()
//设置默认罗盘
.
setOpenNavi
()
//开启导航
.
setOpenSearch
()
//开启搜索
//
.setOpenNavi()//开启导航
//
.setOpenSearch()//开启搜索
// .setOpenHotPots()//开启热力图
.
setOpenCluster
()
//开启聚合
// .setOpenCluster()//开启聚合
.
setOpenDraw
()
//开启绘制
.
createArcGisFounder
();
//创建ArcGisFounder地图实例
IArcGisZoomOption
iArcGisZoomOption
=
arcGisFounder
.
arcGisZoomOption
();
...
...
arcgislib/proguard-rules.pro
View file @
95981ce8
...
...
@@ -190,11 +190,14 @@
-keep class cn.com.founder.arcgislib.navi.option.
*
*{ *; }
-keep class cn.com.founder.arcgislib.cluster.listener.
*
*{ *; }
-keep class cn.com.founder.arcgislib.cluster.option.
*
*{ *; }
-keep class cn.com.founder.arcgislib.draw.listener.
*
*{ *; }
-keep class cn.com.founder.arcgislib.draw.option.
*
*{ *; }
-keep class cn.com.founder.arcgislib.hotpots.option.
*
*{ *; }
-keep class cn.com.founder.arcgislib.model.
*
*{ *; }
-keep class cn.com.founder.arcgislib.view.
*
*{ *; }
-keep class cn.com.founder.arcgislib.widget.
*
*{ *; }
-keep class cn.com.founder.arcgislib.widget.cluster.
*
*{ *; }
-keep class cn.com.founder.arcgislib.widget.draw.
*
*{ *; }
-keep class cn.com.founder.arcgislib.widget.navi.
*
*{ *; }
-keep class cn.com.founder.arcgislib.widget.popup.
*
*{ *; }
...
...
arcgislib/src/main/java/cn/com/founder/arcgislib/ArcGisFounder.java
View file @
95981ce8
...
...
@@ -18,6 +18,8 @@ import cn.com.founder.arcgislib.cluster.ArcGisCluster;
import
cn.com.founder.arcgislib.cluster.option.IArcGisClusterOption
;
import
cn.com.founder.arcgislib.compass.ArcGisCompass
;
import
cn.com.founder.arcgislib.compass.option.IArcGisCompassOption
;
import
cn.com.founder.arcgislib.draw.ArcGisDraw
;
import
cn.com.founder.arcgislib.draw.option.IArcGisDrawOption
;
import
cn.com.founder.arcgislib.hotpots.ArcGisHotPots
;
import
cn.com.founder.arcgislib.hotpots.option.IArcGisHotPotsOption
;
import
cn.com.founder.arcgislib.location.ArcGisLocation
;
...
...
@@ -35,6 +37,7 @@ import cn.com.founder.arcgislib.source.XFragmentSource;
import
cn.com.founder.arcgislib.utils.ToolUtil
;
import
cn.com.founder.arcgislib.view.ArcGisBaseView
;
import
cn.com.founder.arcgislib.view.ArcGisClusterView
;
import
cn.com.founder.arcgislib.view.ArcGisDrawView
;
import
cn.com.founder.arcgislib.view.ArcGisHotPotsView
;
import
cn.com.founder.arcgislib.view.ArcGisLocationView
;
import
cn.com.founder.arcgislib.view.ArcGisMapCompassView
;
...
...
@@ -175,6 +178,11 @@ public class ArcGisFounder implements IOption {
return
mArcGisFounderBuilder
.
mIArcGisClusterOption
;
}
@Override
public
IArcGisDrawOption
arcGisDrawOption
()
{
return
mArcGisFounderBuilder
.
mIArcGisDrawOption
;
}
/**
* 外面暴露ArcGisLib相关方法,利用builder模式
*/
...
...
@@ -229,6 +237,10 @@ public class ArcGisFounder implements IOption {
*/
private
ArcGisClusterView
mArcGisClusterView
;
/**
* {@link ArcGisDrawView}
*/
private
ArcGisDrawView
mArcGisDrawView
;
/**
* {@link IArcGisZoomOption}
*/
private
IArcGisZoomOption
mIArcGisZoomOption
;
...
...
@@ -253,10 +265,14 @@ public class ArcGisFounder implements IOption {
*/
private
IArcGisHotPotsOption
mIArcGisHotPotsOption
;
/**
* {@link IArcGis
HotPots
Option}
* {@link IArcGis
Cluster
Option}
*/
private
IArcGisClusterOption
mIArcGisClusterOption
;
/**
* {@link IArcGisDrawOption}
*/
private
IArcGisDrawOption
mIArcGisDrawOption
;
/**
* 地图网格背景
*/
private
int
mBackgroundGridColor
=
-
1
;
...
...
@@ -377,6 +393,15 @@ public class ArcGisFounder implements IOption {
}
/**
* @return 开启绘制功能,默认不开启
*/
public
ArcGisFounderBuilder
setOpenDraw
()
{
this
.
mArcGisDrawView
=
new
PreCustomView
(
this
).
getArcGisDrawView
();
this
.
mIArcGisDrawOption
=
new
PreCommonMapOption
(
this
).
defaultArcGisDrawOption
();
return
this
;
}
/**
* @return {@link PreArcGisFounder}
*/
public
ArcGisFounder
createArcGisFounder
()
{
...
...
@@ -457,6 +482,13 @@ public class ArcGisFounder implements IOption {
return
new
ArcGisClusterView
(
mArcGisFounderBuilder
.
mSource
.
getContext
(),
mArcGisFounderBuilder
.
mArcGisMapView
,
mArcGisFounderBuilder
.
mArcGisLocationView
);
}
/**
* @return {@link ArcGisDrawView}
*/
ArcGisDrawView
getArcGisDrawView
()
{
return
new
ArcGisDrawView
(
mArcGisFounderBuilder
.
mSource
.
getContext
(),
mArcGisFounderBuilder
.
mArcGisMapView
,
mArcGisFounderBuilder
.
mArcGisLocationView
);
}
}
/**
...
...
@@ -514,6 +546,10 @@ public class ArcGisFounder implements IOption {
mArcGisFounderBuilder
.
mArcGisBaseView
.
addView
(
mArcGisFounderBuilder
.
mArcGisClusterView
);
}
if
(
mArcGisFounderBuilder
.
mArcGisDrawView
!=
null
)
{
mArcGisFounderBuilder
.
mArcGisBaseView
.
addView
(
mArcGisFounderBuilder
.
mArcGisDrawView
);
}
if
(!
ToolUtil
.
isNetWorkAvailable
(
mArcGisFounderBuilder
.
mSource
.
getContext
()))
{
Toast
.
makeText
(
mArcGisFounderBuilder
.
mSource
.
getContext
(),
mArcGisFounderBuilder
.
mSource
.
getContext
().
getString
(
R
.
string
.
string_net
),
Toast
.
LENGTH_LONG
).
show
();
mArcGisFounderBuilder
.
mArcGisBaseView
.
setVisibility
(
View
.
GONE
);
...
...
@@ -582,6 +618,12 @@ public class ArcGisFounder implements IOption {
IArcGisClusterOption
defaultArcGisClusterOption
()
{
return
new
ArcGisCluster
(
mArcGisFounderBuilder
.
mArcGisClusterView
);
}
/**
* @return {@link IArcGisDrawOption}
*/
IArcGisDrawOption
defaultArcGisDrawOption
()
{
return
new
ArcGisDraw
(
mArcGisFounderBuilder
.
mArcGisDrawView
);
}
}
}
...
...
arcgislib/src/main/java/cn/com/founder/arcgislib/common/Variable.java
View file @
95981ce8
...
...
@@ -15,7 +15,9 @@ public class Variable {
TEXT
,
POINT
,
LINE
,
POLYGON
;
POLYGON
,
ORTHOGON
,
CIRCLE
;
}
public
static
enum
GraphType
{
LINE
,
...
...
arcgislib/src/main/java/cn/com/founder/arcgislib/option/IOption.java
View file @
95981ce8
...
...
@@ -2,6 +2,7 @@ package cn.com.founder.arcgislib.option;
import
cn.com.founder.arcgislib.cluster.option.IArcGisClusterOption
;
import
cn.com.founder.arcgislib.compass.option.IArcGisCompassOption
;
import
cn.com.founder.arcgislib.draw.option.IArcGisDrawOption
;
import
cn.com.founder.arcgislib.hotpots.option.IArcGisHotPotsOption
;
import
cn.com.founder.arcgislib.location.option.IArcGisLocationOption
;
import
cn.com.founder.arcgislib.navi.option.IArcGisNaviOption
;
...
...
@@ -52,5 +53,10 @@ public interface IOption {
*/
IArcGisClusterOption
arcGisClusterOption
();
/**
* 绘制操作
*/
IArcGisDrawOption
arcGisDrawOption
();
}
arcgislib/src/main/java/cn/com/founder/arcgislib/view/ArcGisClusterView.java
View file @
95981ce8
...
...
@@ -252,7 +252,7 @@ public class ArcGisClusterView extends LinearLayout implements View.OnClickListe
isFirstCreate
=
false
;
if
(
mArcGisLocationView
!=
null
){
mArcGisLocationView
.
isUseCluster
=
true
;
mArcGisLocationView
.
preventClick
=
true
;
}
}
});
...
...
@@ -342,7 +342,7 @@ public class ArcGisClusterView extends LinearLayout implements View.OnClickListe
public
void
onSingleTap
(
MotionEvent
motionEvent
)
{
if
(
clusterLayer
==
null
){
if
(
mArcGisLocationView
!=
null
){
mArcGisLocationView
.
isUseCluster
=
false
;
mArcGisLocationView
.
preventClick
=
false
;
}
return
;
}
...
...
arcgislib/src/main/java/cn/com/founder/arcgislib/view/ArcGisDrawView.java
0 → 100644
View file @
95981ce8
package
cn
.
com
.
founder
.
arcgislib
.
view
;
import
android.content.Context
;
import
android.util.AttributeSet
;
import
android.view.Gravity
;
import
android.view.MotionEvent
;
import
android.view.View
;
import
android.widget.ImageView
;
import
android.widget.LinearLayout
;
import
android.widget.RelativeLayout
;
import
androidx.annotation.Nullable
;
import
com.esri.arcgisruntime.mapping.view.MapView
;
import
cn.com.founder.arcgislib.R
;
import
cn.com.founder.arcgislib.common.Variable
;
import
cn.com.founder.arcgislib.widget.draw.DrawEntity
;
import
cn.com.founder.arcgislib.widget.draw.DrawLayer
;
import
cn.com.founder.arcgislib.widget.draw.DrawView
;
/**
* Copyright: 方正国际软件有限公司
* Author:luo_shaopeng
* Date:2020/7/3 10:42
* EMail:luo_shaopeng@founder.com.cn
* Description:绘制
*/
public
class
ArcGisDrawView
extends
LinearLayout
implements
View
.
OnClickListener
,
ArcGisMapView
.
MyTouchDrawListener
{
protected
static
ArcGisDrawView
instance
;
/**
* {@link Context}
*/
private
Context
mContext
;
/**
* 绘制根布局
*/
private
RelativeLayout
mDrawTotalLayout
;
/**
* 绘制图片布局
*/
protected
RelativeLayout
mDrawIvLayout
;
/**
* 绘制图片
*/
protected
ImageView
mDrawIv
;
/**
* 绘制操作内容
*/
private
LinearLayout
mDrawContentLayout
;
/**
* 绘制线
*/
private
LinearLayout
mDrawLineLayout
;
/**
* 绘制圆
*/
private
LinearLayout
mDrawCircleLayout
;
/**
* 绘制矩形
*/
private
LinearLayout
mDrawOrthogonLayout
;
/**
* 绘制多边形
*/
private
LinearLayout
mDrawPolygonLayout
;
/**
* 撤销
*/
private
LinearLayout
mDrawPrevLayout
;
/**
* 恢复
*/
private
LinearLayout
mDrawNextLayout
;
/**
* 清除
*/
private
LinearLayout
mDrawClearLayout
;
/**
* 完成
*/
private
LinearLayout
mDrawEndLayout
;
/**
* {@link ArcGisMapView}
*/
private
ArcGisMapView
mArcGisMapView
;
private
ArcGisLocationView
mArcGisLocationView
;
/**
* {@link MapView}
*/
private
MapView
mMapView
;
/**
* {@link DrawLayer}
*/
private
DrawView
mDrawView
;
private
Variable
.
DrawType
drawType
=
null
;
private
Variable
.
Measure
measureLengthType
=
Variable
.
Measure
.
M
;
private
Variable
.
Measure
measureAreaType
=
Variable
.
Measure
.
M2
;
public
ArcGisDrawView
(
Context
context
,
ArcGisMapView
arcGisMapView
,
ArcGisLocationView
arcGisLocationView
)
{
this
(
context
);
this
.
mContext
=
context
;
this
.
mArcGisMapView
=
arcGisMapView
;
this
.
mMapView
=
mArcGisMapView
.
getMapView
();
this
.
mArcGisLocationView
=
arcGisLocationView
;
if
(
mArcGisLocationView
!=
null
){
mArcGisLocationView
.
preventClick
=
true
;
}
arcGisMapView
.
setMyTouchDrawListener
(
this
);
mDrawView
=
new
DrawView
(
context
,
mMapView
);
}
private
ArcGisDrawView
(
Context
context
)
{
this
(
context
,
null
,
0
);
}
private
ArcGisDrawView
(
Context
context
,
@Nullable
AttributeSet
attrs
)
{
this
(
context
,
attrs
,
0
);
}
private
ArcGisDrawView
(
Context
context
,
@Nullable
AttributeSet
attrs
,
int
defStyleAttr
)
{
super
(
context
,
attrs
,
defStyleAttr
);
inflate
(
context
,
R
.
layout
.
layout_draw
,
this
);
instance
=
this
;
mDrawTotalLayout
=
findViewById
(
R
.
id
.
draw_layout
);
mDrawIvLayout
=
findViewById
(
R
.
id
.
draw_iv_layout
);
mDrawIv
=
findViewById
(
R
.
id
.
draw_iv
);
mDrawContentLayout
=
findViewById
(
R
.
id
.
draw_content_layout
);
mDrawLineLayout
=
findViewById
(
R
.
id
.
draw_line_layout
);
mDrawCircleLayout
=
findViewById
(
R
.
id
.
draw_circle_layout
);
mDrawOrthogonLayout
=
findViewById
(
R
.
id
.
draw_orthogon_layout
);
mDrawPolygonLayout
=
findViewById
(
R
.
id
.
draw_polygon_layout
);
mDrawPrevLayout
=
findViewById
(
R
.
id
.
draw_prev_layout
);
mDrawNextLayout
=
findViewById
(
R
.
id
.
draw_next_layout
);
mDrawClearLayout
=
findViewById
(
R
.
id
.
draw_clear_layout
);
mDrawEndLayout
=
findViewById
(
R
.
id
.
draw_end_layout
);
mDrawIv
.
setOnClickListener
(
this
);
mDrawLineLayout
.
setOnClickListener
(
this
);
mDrawCircleLayout
.
setOnClickListener
(
this
);
mDrawOrthogonLayout
.
setOnClickListener
(
this
);
mDrawPolygonLayout
.
setOnClickListener
(
this
);
mDrawPrevLayout
.
setOnClickListener
(
this
);
mDrawNextLayout
.
setOnClickListener
(
this
);
mDrawClearLayout
.
setOnClickListener
(
this
);
mDrawEndLayout
.
setOnClickListener
(
this
);
}
@Override
public
void
onClick
(
View
view
)
{
if
(
view
.
getId
()
==
R
.
id
.
draw_iv
)
{
if
(
mDrawContentLayout
.
getVisibility
()
==
View
.
VISIBLE
)
{
mDrawContentLayout
.
setVisibility
(
View
.
GONE
);
}
else
{
mDrawContentLayout
.
setVisibility
(
View
.
VISIBLE
);
}
}
else
if
(
view
.
getId
()
==
R
.
id
.
draw_line_layout
)
{
//线
drawType
=
Variable
.
DrawType
.
LINE
;
mDrawView
.
endMeasure
();
}
else
if
(
view
.
getId
()
==
R
.
id
.
draw_circle_layout
)
{
//圆
drawType
=
Variable
.
DrawType
.
CIRCLE
;
}
else
if
(
view
.
getId
()
==
R
.
id
.
draw_orthogon_layout
)
{
//矩形
drawType
=
Variable
.
DrawType
.
ORTHOGON
;
}
else
if
(
view
.
getId
()
==
R
.
id
.
draw_polygon_layout
)
{
//多边形
drawType
=
Variable
.
DrawType
.
POLYGON
;
mDrawView
.
endMeasure
();
}
else
if
(
view
.
getId
()
==
R
.
id
.
draw_prev_layout
)
{
//撤销
boolean
hasPrev
=
mDrawView
.
prevDraw
();
}
else
if
(
view
.
getId
()
==
R
.
id
.
draw_next_layout
)
{
//恢复
boolean
hasNext
=
mDrawView
.
nextDraw
();
}
else
if
(
view
.
getId
()
==
R
.
id
.
draw_clear_layout
)
{
//清除
drawType
=
null
;
DrawEntity
draw
=
mDrawView
.
clearMeasure
();
}
else
if
(
view
.
getId
()
==
R
.
id
.
draw_end_layout
)
{
//完成
drawType
=
null
;
DrawEntity
draw
=
mDrawView
.
endMeasure
();
}
}
/**
* @param isShow boolean-是否显示绘制布局
* 默认显示
*/
public
void
setShowDrawLayout
(
boolean
isShow
)
{
if
(
isShow
)
{
mDrawTotalLayout
.
setVisibility
(
VISIBLE
);
}
else
{
mDrawTotalLayout
.
setVisibility
(
GONE
);
}
}
/**
* @param location {@link Variable.ViewLocation } DrawView显示位置
*/
public
void
setDrawViewLocation
(
Variable
.
ViewLocation
location
)
{
switch
(
location
)
{
case
LEFT_TOP:
mDrawIvLayout
.
setGravity
(
Gravity
.
LEFT
|
Gravity
.
TOP
);
break
;
case
RIGHT_TOP:
mDrawIvLayout
.
setGravity
(
Gravity
.
RIGHT
|
Gravity
.
TOP
);
break
;
case
CENTER:
mDrawIvLayout
.
setGravity
(
Gravity
.
CENTER
);
break
;
case
LEFT_BOTTOM:
mDrawIvLayout
.
setGravity
(
Gravity
.
LEFT
|
Gravity
.
BOTTOM
);
break
;
case
RIGHT_BOTTOM:
mDrawIvLayout
.
setGravity
(
Gravity
.
RIGHT
|
Gravity
.
BOTTOM
);
break
;
}
}
/**
* @param drawImage int(资源ID)-绘制图片
*/
public
void
setDrawImage
(
int
drawImage
)
{
mDrawIv
.
setImageDrawable
(
getResources
().
getDrawable
(
drawImage
));
}
@Override
public
void
onMapSingleTapUp
(
MotionEvent
e
)
{
if
(
drawType
==
Variable
.
DrawType
.
LINE
)
{
mDrawView
.
startMeasuredLength
(
e
.
getX
(),
e
.
getY
());
}
else
if
(
drawType
==
Variable
.
DrawType
.
POLYGON
){
mDrawView
.
startMeasuredArea
(
e
.
getX
(),
e
.
getY
());
}
else
if
(
drawType
==
Variable
.
DrawType
.
CIRCLE
){
mDrawView
.
drawCircle
(
e
.
getX
(),
e
.
getY
());
}
else
if
(
drawType
==
Variable
.
DrawType
.
ORTHOGON
){
mDrawView
.
drawBox
(
e
.
getX
(),
e
.
getY
());
}
}
}
arcgislib/src/main/java/cn/com/founder/arcgislib/view/ArcGisLocationView.java
View file @
95981ce8
...
...
@@ -223,9 +223,9 @@ public class ArcGisLocationView extends LinearLayout implements View.OnClickList
private
double
distance
=
0.1
;
/**
*
使用聚合时使用此字段
*
阻止点击
*/
protected
boolean
isUseCluster
=
false
;
protected
boolean
preventClick
=
false
;
public
ArcGisLocationView
(
Context
context
,
ArcGisMapView
arcGisMapView
)
{
this
(
context
);
...
...
@@ -1061,7 +1061,7 @@ public class ArcGisLocationView extends LinearLayout implements View.OnClickList
@Override
public
void
onUp
(
Variable
.
TouchUp
touchUp
,
MotionEvent
motionEvent
)
{
if
(
isUseCluster
)
if
(
preventClick
)
return
;
if
(
touchUp
==
Variable
.
TouchUp
.
UP
&&
mFollowMapGetCenterPoint
)
{
final
android
.
graphics
.
Point
screenPoint
=
new
android
.
graphics
.
Point
(
...
...
@@ -1120,7 +1120,7 @@ public class ArcGisLocationView extends LinearLayout implements View.OnClickList
@Override
public
void
onSingleTap
(
MotionEvent
motionEvent
)
{
if
(
isUseCluster
)
if
(
preventClick
)
return
;
switch
(
currSearchType
)
{
case
SEARCH:
...
...
@@ -1134,7 +1134,7 @@ public class ArcGisLocationView extends LinearLayout implements View.OnClickList
@Override
public
void
onLongPress
(
MotionEvent
motionEvent
)
{
if
(
isUseCluster
)
if
(
preventClick
)
return
;
switch
(
currSearchType
)
{
case
SEARCH:
...
...
arcgislib/src/main/java/cn/com/founder/arcgislib/view/ArcGisMapView.java
View file @
95981ce8
...
...
@@ -240,6 +240,14 @@ public class ArcGisMapView extends LinearLayout {
}
@Override
public
boolean
onSingleTapUp
(
MotionEvent
e
)
{
if
(
myTouchDrawListener
!=
null
)
{
myTouchDrawListener
.
onMapSingleTapUp
(
e
);
}
return
super
.
onSingleTapUp
(
e
);
}
@Override
public
void
onLongPress
(
MotionEvent
motionEvent
)
{
super
.
onLongPress
(
motionEvent
);
mLongPressEvent
=
motionEvent
;
...
...
@@ -265,6 +273,7 @@ public class ArcGisMapView extends LinearLayout {
private
MyTouchLocationListener
myTouchLocationListener
;
private
MyTouchCompassListener
myTouchCompassListener
;
private
MyTouchClusterListener
myTouchClusterListener
;
private
MyTouchDrawListener
myTouchDrawListener
;
protected
void
setMyTouchLocationListener
(
MyTouchLocationListener
touchListener
)
{
this
.
myTouchLocationListener
=
touchListener
;
...
...
@@ -278,6 +287,10 @@ public class ArcGisMapView extends LinearLayout {
this
.
myTouchClusterListener
=
touchListener
;
}
protected
void
setMyTouchDrawListener
(
MyTouchDrawListener
touchListener
)
{
this
.
myTouchDrawListener
=
touchListener
;
}
/**
* 位置触摸监听类
*/
...
...
@@ -346,4 +359,16 @@ public class ArcGisMapView extends LinearLayout {
void
onSingleTap
(
MotionEvent
motionEvent
);
}
/**
* 绘制触摸监听类
*/
interface
MyTouchDrawListener
{
/**
* 单击并抬起
*
* @param motionEvent 移动事件
*/
void
onMapSingleTapUp
(
MotionEvent
motionEvent
);
}
}
arcgislib/src/main/java/cn/com/founder/arcgislib/widget/draw/DrawEntity.java
0 → 100644
View file @
95981ce8
package
cn
.
com
.
founder
.
arcgislib
.
widget
.
draw
;
import
com.esri.arcgisruntime.geometry.Point
;
import
com.esri.arcgisruntime.mapping.view.GraphicsOverlay
;
import
java.util.List
;
public
class
DrawEntity
{
private
List
<
GraphicsOverlay
>
textGraphic
=
null
;
//文字集合
private
List
<
GraphicsOverlay
>
polygonGraphic
=
null
;
//面集合
private
List
<
GraphicsOverlay
>
lineGraphic
=
null
;
//线集合
private
List
<
GraphicsOverlay
>
pointGraphic
=
null
;
//点集合
private
List
<
List
<
Point
>>
pointGroup
=
null
;
//绘制点的集合的集合
public
DrawEntity
(
List
<
GraphicsOverlay
>
textGraphic
,
List
<
GraphicsOverlay
>
polygonGraphic
,
List
<
GraphicsOverlay
>
lineGraphic
,
List
<
GraphicsOverlay
>
pointGraphic
,
List
<
List
<
Point
>>
pointGroup
)
{
this
.
textGraphic
=
textGraphic
;
this
.
polygonGraphic
=
polygonGraphic
;
this
.
lineGraphic
=
lineGraphic
;
this
.
pointGraphic
=
pointGraphic
;
this
.
pointGroup
=
pointGroup
;
}
public
DrawEntity
(){
}
public
List
<
GraphicsOverlay
>
getTextGraphic
()
{
return
textGraphic
;
}
public
void
setTextGraphic
(
List
<
GraphicsOverlay
>
textGraphic
)
{
this
.
textGraphic
=
textGraphic
;
}
public
List
<
GraphicsOverlay
>
getPolygonGraphic
()
{
return
polygonGraphic
;
}
public
void
setPolygonGraphic
(
List
<
GraphicsOverlay
>
polygonGraphic
)
{
this
.
polygonGraphic
=
polygonGraphic
;
}
public
List
<
GraphicsOverlay
>
getLineGraphic
()
{
return
lineGraphic
;
}
public
void
setLineGraphic
(
List
<
GraphicsOverlay
>
lineGraphic
)
{
this
.
lineGraphic
=
lineGraphic
;
}
public
List
<
GraphicsOverlay
>
getPointGraphic
()
{
return
pointGraphic
;
}
public
void
setPointGraphic
(
List
<
GraphicsOverlay
>
pointGraphic
)
{
this
.
pointGraphic
=
pointGraphic
;
}
public
List
<
List
<
Point
>>
getPointGroup
()
{
return
pointGroup
;
}
public
void
setPointGroup
(
List
<
List
<
Point
>>
pointGroup
)
{
this
.
pointGroup
=
pointGroup
;
}
}
arcgislib/src/main/java/cn/com/founder/arcgislib/widget/draw/DrawLayer.java
0 → 100644
View file @
95981ce8
This diff is collapsed.
Click to expand it.
arcgislib/src/main/java/cn/com/founder/arcgislib/widget/draw/DrawView.java
0 → 100644
View file @
95981ce8
package
cn
.
com
.
founder
.
arcgislib
.
widget
.
draw
;
import
android.content.Context
;
import
com.esri.arcgisruntime.geometry.GeodeticCurveType
;
import
com.esri.arcgisruntime.geometry.GeometryEngine
;
import
com.esri.arcgisruntime.geometry.Point
;
import
com.esri.arcgisruntime.geometry.PolygonBuilder
;
import
com.esri.arcgisruntime.geometry.PolylineBuilder
;
import
com.esri.arcgisruntime.geometry.SpatialReference
;
import
com.esri.arcgisruntime.mapping.view.MapView
;
import
java.util.ArrayList
;
import
java.util.List
;
import
cn.com.founder.arcgislib.common.Variable
;
import
cn.com.founder.arcgislib.utils.ToolUtil
;
/**
* Copyright: 方正国际软件有限公司
* Author:luo_shaopeng
* Date:2020/7/3 17:33
* EMail:luo_shaopeng@founder.com.cn
* Description:绘制
*/
public
class
DrawView
extends
DrawLayer
{
private
Context
context
;
private
MapView
mapView
;
private
Variable
.
DrawType
drawType
=
null
;
private
Variable
.
Measure
measureLengthType
=
Variable
.
Measure
.
M
;
private
Variable
.
Measure
measureAreaType
=
Variable
.
Measure
.
M2
;
private
double
lineLength
=
0
;
private
List
<
Double
>
lengthList
;
private
List
<
Double
>
tmpLengthList
;
public
DrawView
(
Context
context
,
MapView
mapView
)
{
super
(
context
,
mapView
);
this
.
context
=
context
;
this
.
mapView
=
mapView
;
lengthList
=
new
ArrayList
<>();
tmpLengthList
=
new
ArrayList
<>();
}
public
void
startMeasuredLength
(
float
screenX
,
float
screenY
){
if
(
drawType
==
null
)
{
super
.
startLine
();
drawType
=
Variable
.
DrawType
.
LINE
;
}
drawScreenXY
(
screenX
,
screenY
);
}
public
void
startMeasuredLength
(
android
.
graphics
.
Point
screenPoint
){
if
(
drawType
==
null
)
{
super
.
startLine
();
drawType
=
Variable
.
DrawType
.
LINE
;
}
drawScreenPoint
(
screenPoint
);
}
public
void
startMeasuredArea
(
float
screenX
,
float
screenY
){
if
(
drawType
==
null
)
{
super
.
startPolygon
();
drawType
=
Variable
.
DrawType
.
POLYGON
;
}
drawScreenXY
(
screenX
,
screenY
);
}
public
void
startMeasuredArea
(
android
.
graphics
.
Point
screenPoint
){
if
(
drawType
==
null
)
{
super
.
startPolygon
();
drawType
=
Variable
.
DrawType
.
POLYGON
;
}
drawScreenPoint
(
screenPoint
);
}
public
boolean
prevDraw
(){
if
(
lengthList
.
size
()>
1
)
{
lengthList
.
remove
(
lengthList
.
size
()
-
1
);
lineLength
=
lengthList
.
get
(
lengthList
.
size
()-
1
);
}
else
{
lengthList
.
clear
();
lineLength
=
0
;
}
return
super
.
prevDraw
();
}
public
boolean
nextDraw
(){
if
(
lengthList
.
size
()>
0
&&
lengthList
.
size
()<
tmpLengthList
.
size
())
{
lengthList
.
add
(
tmpLengthList
.
get
(
lengthList
.
size
()));
lineLength
=
lengthList
.
get
(
lengthList
.
size
()-
1
);
}
return
super
.
nextDraw
();
}
public
DrawEntity
endMeasure
(){
drawType
=
null
;
lineLength
=
0
;
tmpLengthList
.
clear
();
lengthList
.
clear
();
return
super
.
endDraw
();
}
public
DrawEntity
clearMeasure
(){
drawType
=
null
;
lineLength
=
0
;
tmpLengthList
.
clear
();
lengthList
.
clear
();
return
super
.
clear
();
}
public
void
setSpatialReference
(
SpatialReference
spatialReference
)
{
super
.
setSpatialReference
(
spatialReference
);
}
public
void
setLengthType
(
Variable
.
Measure
type
){
this
.
measureLengthType
=
type
;
}
public
void
setAreaType
(
Variable
.
Measure
type
){
this
.
measureAreaType
=
type
;
}
private
void
drawScreenXY
(
float
x
,
float
y
){
Point
point
=
super
.
screenXYtoPpoint
(
x
,
y
);
if
(
drawType
==
Variable
.
DrawType
.
LINE
){
PolylineBuilder
line
=(
PolylineBuilder
)
super
.
drawByGisPoint
(
point
);
showLength
(
line
,
point
);
}
else
if
(
drawType
==
Variable
.
DrawType
.
POLYGON
){
PolygonBuilder
polygon
=(
PolygonBuilder
)
super
.
drawByGisPoint
(
point
);
showArea
(
polygon
);
}
}
private
void
drawScreenPoint
(
android
.
graphics
.
Point
screenPoint
){
Point
point
=
super
.
screenXYtoPpoint
(
screenPoint
.
x
,
screenPoint
.
y
);
if
(
drawType
==
Variable
.
DrawType
.
LINE
){
PolylineBuilder
line
=(
PolylineBuilder
)
super
.
drawByScreenPoint
(
screenPoint
);
showLength
(
line
,
point
);
}
else
if
(
drawType
==
Variable
.
DrawType
.
POLYGON
){
PolygonBuilder
polygon
=(
PolygonBuilder
)
super
.
drawByScreenPoint
(
screenPoint
);
showArea
(
polygon
);
}
}
private
void
showLength
(
PolylineBuilder
line
,
Point
point
){
if
(
line
!=
null
)
{
//double length = GeometryEngine.length(line.toGeometry());
double
length
=
GeometryEngine
.
lengthGeodetic
(
line
.
toGeometry
(),
null
,
GeodeticCurveType
.
SHAPE_PRESERVING
);
lineLength
+=
length
;
lengthList
.
add
(
lineLength
);
tmpLengthList
.
clear
();
tmpLengthList
.
addAll
(
lengthList
);
String
s
=
ToolUtil
.
forMatDouble
(
Math
.
abs
(
ToolUtil
.
lengthChange
(
lineLength
,
measureLengthType
)));
super
.
drawText
(
point
,
s
+
ToolUtil
.
lengthEnameToCname
(
measureLengthType
),
false
);
}
}
private
void
showArea
(
PolygonBuilder
polygon
){
if
(
polygon
!=
null
)
{
//double area = GeometryEngine.area(polygon.toGeometry());
double
area
=
GeometryEngine
.
areaGeodetic
(
polygon
.
toGeometry
(),
null
,
GeodeticCurveType
.
SHAPE_PRESERVING
);
String
s
=
ToolUtil
.
forMatDouble
(
Math
.
abs
(
ToolUtil
.
areaChange
(
area
,
measureAreaType
)));
super
.
drawText
(
polygon
.
toGeometry
().
getExtent
().
getCenter
(),
s
+
ToolUtil
.
lengthEnameToCname
(
measureAreaType
),
true
);
}
}
}
arcgislib/src/main/res/values/colors.xml
View file @
95981ce8
...
...
@@ -12,8 +12,11 @@
<color
name=
"color_CCCCCC"
>
#CCCCCC
</color>
<color
name=
"color_E6E6E6"
>
#E6E6E6
</color>
<color
name=
"color_BFBFBF"
>
#BFBFBF
</color>
<color
name=
"color_444444"
>
#444444
</color>
<color
name=
"color_13227A"
>
#13227A
</color>
<color
name=
"color_1A34BC"
>
#1A34BC
</color>
<color
name=
"color_F05B48"
>
#F05B48
</color>
<color
name=
"color_515151"
>
#515151
</color>
...
...
arcgislib/src/main/res/values/dimens.xml
View file @
95981ce8
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen
name=
"dimen_block_35"
>
35dp
</dimen>
<dimen
name=
"dimen_block_30"
>
30dp
</dimen>
<dimen
name=
"dimen_block_25"
>
25dp
</dimen>
<dimen
name=
"dimen_block_20"
>
20dp
</dimen>
...
...
arcgislib/src/main/res/values/strings.xml
View file @
95981ce8
...
...
@@ -36,4 +36,16 @@
<string
name=
"string_hotpots_end_time"
>
结束时间
</string>
<string
name=
"string_hotpots_input_hint"
>
请选择
</string>
<string
name=
"string_hotpots_finish"
>
完成
</string>
<!--绘制-->
<string
name=
"string_draw_line"
>
线
</string>
<string
name=
"string_draw_circle"
>
圆
</string>
<string
name=
"string_draw_orthogon"
>
矩形
</string>
<string
name=
"string_draw_polygon"
>
多边形
</string>
<string
name=
"string_draw_prev"
>
撤销
</string>
<string
name=
"string_draw_next"
>
恢复
</string>
<string
name=
"string_draw_clear"
>
清除
</string>
<string
name=
"string_draw_end"
>
完成
</string>
</resources>
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