Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
x649585723
incubator-echarts
提交
e40cb33a
I
incubator-echarts
项目概览
x649585723
/
incubator-echarts
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
incubator-echarts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e40cb33a
编写于
12月 19, 2013
作者:
K
kener
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
子地区模式升级
上级
7a2acc84
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
114 addition
and
43 deletion
+114
-43
src/chart/map.js
src/chart/map.js
+113
-42
src/util/projection/normal.js
src/util/projection/normal.js
+1
-1
未找到文件。
src/chart/map.js
浏览文件 @
e40cb33a
...
...
@@ -161,11 +161,12 @@ define(function(require) {
_mapDataMap
[
mt
].
mapData
)
}
else
if
(
_mapParams
[
mt
].
getGeoJson
)
{
else
if
(
_mapParams
[
mt
.
replace
(
/
\|
.*/
,
''
)
].
getGeoJson
)
{
// 特殊区域
_specialArea
[
mt
]
=
_mapParams
[
mt
].
specialArea
||
_specialArea
[
mt
];
_mapParams
[
mt
].
getGeoJson
(
_specialArea
[
mt
]
=
_mapParams
[
mt
.
replace
(
/
\|
.*/
,
''
)].
specialArea
||
_specialArea
[
mt
];
_mapParams
[
mt
.
replace
(
/
\|
.*/
,
''
)].
getGeoJson
(
_mapDataCallback
(
mt
,
valueData
[
mt
],
mapSeries
[
mt
])
);
}
...
...
@@ -179,7 +180,12 @@ define(function(require) {
*/
function
_mapDataCallback
(
mt
,
vd
,
ms
)
{
return
function
(
md
)
{
_mapDataMap
[
mt
].
mapData
=
md
;
// 缓存这份数据
// 缓存这份数据
if
(
mt
.
indexOf
(
'
|
'
)
!=
-
1
)
{
// 子地图,加工一份新的mapData
md
=
_getSubMapData
(
mt
,
md
);
}
_mapDataMap
[
mt
].
mapData
=
md
;
_buildMap
(
mt
,
// 类型
_getProjectionData
(
// 地图数据
...
...
@@ -200,6 +206,39 @@ define(function(require) {
};
}
function
_getSubMapData
(
mapType
,
mapData
)
{
var
subType
=
mapType
.
replace
(
/^.*
\|
/
,
''
);
var
features
=
mapData
.
features
;
for
(
var
i
=
0
,
l
=
features
.
length
;
i
<
l
;
i
++
)
{
if
(
features
[
i
].
properties
&&
features
[
i
].
properties
.
name
==
subType
)
{
features
=
features
[
i
];
if
(
subType
==
'
United States of America
'
&&
features
.
geometry
.
coordinates
.
length
>
1
// 未被简化
)
{
features
=
{
geometry
:
{
coordinates
:
features
.
geometry
.
coordinates
.
slice
(
5
,
6
),
type
:
features
.
geometry
.
type
},
id
:
features
.
id
,
properties
:
features
.
properties
,
type
:
features
.
type
,
}
}
break
;
}
}
return
{
'
type
'
:
'
FeatureCollection
'
,
'
features
'
:[
features
]
}
}
/**
* 按需加载相关地图
*/
...
...
@@ -320,25 +359,11 @@ define(function(require) {
* 特殊地区投射数据
*/
function
_getSpecialProjectionData
(
mapType
,
oriM
apData
,
areaName
,
mapSize
,
position
mapType
,
m
apData
,
areaName
,
mapSize
,
position
)
{
//console.log('_getSpecialProjectionData--------------')
// 构造单独的geoJson地图数据
var
mapData
;
var
features
=
oriMapData
.
features
;
for
(
var
i
=
0
,
l
=
features
.
length
;
i
<
l
;
i
++
)
{
if
(
features
[
i
].
properties
&&
features
[
i
].
properties
.
name
==
areaName
)
{
mapData
=
{
'
type
'
:
'
FeatureCollection
'
,
'
features
'
:[
features
[
i
]
]
}
break
;
}
}
mapData
=
_getSubMapData
(
'
x|
'
+
areaName
,
mapData
);
// bbox
var
normalProjection
=
require
(
'
../util/projection/normal
'
);
...
...
@@ -449,21 +474,31 @@ define(function(require) {
height
=
mapLocation
.
height
||
height
;
}
x
=
isNaN
(
cusX
)
?
padding
:
cusX
;
y
=
isNaN
(
cusY
)
?
padding
:
cusY
;
//x = isNaN(cusX) ? padding : cusX;
x
=
self
.
parsePercent
(
cusX
,
zrWidth
);
x
=
isNaN
(
x
)
?
padding
:
x
;
//y = isNaN(cusY) ? padding : cusY;
y
=
self
.
parsePercent
(
cusY
,
zrHeight
);
y
=
isNaN
(
y
)
?
padding
:
y
;
if
(
typeof
width
==
'
undefined
'
)
{
width
=
zrWidth
;
if
(
x
+
width
>
zrWidth
)
{
width
=
zrWidth
-
x
-
2
*
padding
;
}
width
=
isNaN
(
cusX
)
?
zrWidth
:
zrWidth
-
x
-
2
*
padding
;
}
else
{
width
=
self
.
parsePercent
(
width
,
zrWidth
);
}
if
(
typeof
height
==
'
undefined
'
)
{
height
=
zrHeight
;
if
(
y
+
height
>
zrHeight
)
{
height
=
zrHeight
-
y
-
2
*
padding
;
}
height
=
isNaN
(
cusY
)
?
zrHeight
:
zrHeight
-
y
-
2
*
padding
;
}
else
{
height
=
self
.
parsePercent
(
height
,
zrHeight
);
}
var
mapWidth
=
bbox
.
width
;
var
mapHeight
=
bbox
.
height
;
//var minScale;
...
...
@@ -494,7 +529,7 @@ define(function(require) {
break
;
//case 'left' :
default
:
x
=
padding
;
//
x = padding;
break
;
}
}
...
...
@@ -509,11 +544,11 @@ define(function(require) {
break
;
//case 'top' :
default
:
y
=
padding
;
//
y = padding;
break
;
}
}
//console.log(
width,height, minScale
)
//console.log(
x,y,width,height
)
return
{
left
:
x
,
top
:
y
,
...
...
@@ -621,7 +656,8 @@ define(function(require) {
queryTarget
,
'
itemStyle.normal.lineStyle.width
'
);
style
.
text
=
name
;
style
.
text
=
_getLabelText
(
name
,
value
,
queryTarget
,
'
normal
'
);
style
.
_text
=
name
;
style
.
textAlign
=
'
center
'
;
style
.
textColor
=
self
.
deepQuery
(
queryTarget
,
...
...
@@ -651,7 +687,10 @@ define(function(require) {
brushType
:
'
both
'
,
x
:
style
.
textX
,
y
:
style
.
textY
,
text
:
style
.
text
,
text
:
_getLabelText
(
name
,
value
,
queryTarget
,
'
normal
'
),
_text
:
name
,
textAlign
:
'
center
'
,
color
:
style
.
textColor
,
strokeColor
:
'
rgba(0,0,0,0)
'
,
...
...
@@ -681,7 +720,10 @@ define(function(require) {
queryTarget
,
'
itemStyle.emphasis.label.show
'
))
{
highlightStyle
.
text
=
name
;
highlightStyle
.
text
=
_getLabelText
(
name
,
value
,
queryTarget
,
'
emphasis
'
);
highlightStyle
.
_text
=
name
;
highlightStyle
.
textAlign
=
'
center
'
;
highlightStyle
.
textColor
=
self
.
deepQuery
(
queryTarget
,
...
...
@@ -770,6 +812,35 @@ define(function(require) {
return
_nameMap
[
mapType
][
name
]
||
name
;
}
/**
* 根据lable.format计算label text
*/
function
_getLabelText
(
name
,
value
,
queryTarget
,
status
)
{
var
formatter
=
self
.
deepQuery
(
queryTarget
,
'
itemStyle.
'
+
status
+
'
.label.formatter
'
);
if
(
formatter
)
{
if
(
typeof
formatter
==
'
function
'
)
{
return
formatter
(
name
,
value
);
}
else
if
(
typeof
formatter
==
'
string
'
)
{
formatter
=
formatter
.
replace
(
'
{a}
'
,
'
{a0}
'
)
.
replace
(
'
{b}
'
,
'
{b0}
'
)
formatter
=
formatter
.
replace
(
'
{a0}
'
,
name
)
.
replace
(
'
{b0}
'
,
value
)
return
formatter
;
}
}
else
{
return
name
;
}
}
function
_findMapTypeByPos
(
mx
,
my
)
{
var
transform
;
var
left
;
...
...
@@ -833,7 +904,7 @@ define(function(require) {
_mapDataMap
[
mapType
].
hasRoam
=
true
;
_mapDataMap
[
mapType
].
transform
=
transform
;
// 经纬度转位置
geoAndPos
=
geo2pos
(
mapType
,
geoAndPos
);
geoAndPos
=
geo2pos
(
mapType
,
geoAndPos
);
// 保持视觉中心
transform
.
left
-=
geoAndPos
[
0
]
-
(
mx
-
left
);
transform
.
top
-=
geoAndPos
[
1
]
-
(
my
-
top
);
...
...
@@ -869,7 +940,7 @@ define(function(require) {
}
function
_onmousemove
(
param
)
{
if
(
!
_mousedown
)
{
if
(
!
_mousedown
||
!
self
)
{
return
;
}
var
event
=
param
.
event
;
...
...
@@ -918,7 +989,7 @@ define(function(require) {
}
var
target
=
param
.
target
;
var
name
=
target
.
style
.
text
;
var
name
=
target
.
style
.
_
text
;
var
len
=
self
.
shapeList
.
length
;
var
mapType
=
target
.
_mapType
||
''
;
if
(
_selectedMode
[
mapType
]
==
'
single
'
)
{
...
...
@@ -927,7 +998,7 @@ define(function(require) {
if
(
_selected
[
p
]
&&
_mapTypeMap
[
p
]
==
mapType
)
{
// 复位那些生效shape(包括文字)
for
(
var
i
=
0
;
i
<
len
;
i
++
)
{
if
(
self
.
shapeList
[
i
].
style
.
text
==
p
)
{
if
(
self
.
shapeList
[
i
].
style
.
_
text
==
p
)
{
self
.
shapeList
[
i
].
style
=
self
.
shapeList
[
i
].
_style
;
zr
.
modShape
(
...
...
@@ -944,7 +1015,7 @@ define(function(require) {
// 更新当前点击shape(包括文字)
for
(
var
i
=
0
;
i
<
len
;
i
++
)
{
if
(
self
.
shapeList
[
i
].
style
.
text
==
name
)
{
if
(
self
.
shapeList
[
i
].
style
.
_
text
==
name
)
{
if
(
_selected
[
name
])
{
self
.
shapeList
[
i
].
style
=
zrUtil
.
clone
(
self
.
shapeList
[
i
].
highlightStyle
...
...
src/util/projection/normal.js
浏览文件 @
e40cb33a
...
...
@@ -172,7 +172,7 @@ define(function() {
convertor
.
scale
=
null
;
convertor
.
offset
=
null
;
if
(
(
!
transform
.
scale
||
!
transform
.
offset
)
&&
!
json
.
srcSize
)
{
if
(
!
json
.
srcSize
)
{
parseSrcSize
(
json
,
specialArea
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录