forked from huiyan-fe/react-bmap
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
4,266 additions
and
4,100 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React, { Component } from 'react'; | ||
import {Map, Arc} from '../../../src' | ||
import {simpleMapStyle} from './mapstyle' | ||
|
||
export default class App extends Component { | ||
render() { | ||
return <Map style={{height: '400px'}} mapStyle={simpleMapStyle} center={{lng: 105.403119, lat: 33.328658}} zoom='5'> | ||
<Arc data={[ | ||
{ | ||
from: { | ||
name: '北京' | ||
}, | ||
to: { | ||
name: '南京' | ||
} | ||
}, | ||
{ | ||
from: { | ||
name: '北京', | ||
}, | ||
to: { | ||
point: { | ||
lng: 101.45934, | ||
lat: 39.135305 | ||
} | ||
} | ||
}, | ||
{ | ||
from: { | ||
name: '北京' | ||
}, | ||
to: { | ||
name: '成都' | ||
} | ||
}, | ||
{ | ||
from: { | ||
name: '北京' | ||
}, | ||
to: { | ||
name: '广州' | ||
} | ||
} | ||
]} /> | ||
</Map> | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
/** | ||
* @file 迁徙组件 | ||
* @author kyle([email protected]) | ||
*/ | ||
|
||
import React from 'react'; | ||
import Component from './component'; | ||
import {DataSet, utilCityCenter, utilCurve, baiduMapLayer} from 'mapv'; | ||
|
||
export default class App extends Component { | ||
|
||
constructor(args) { | ||
super(args); | ||
this.state = { | ||
}; | ||
} | ||
|
||
/** | ||
* 设置默认的props属性 | ||
*/ | ||
static get defaultProps() { | ||
return { | ||
} | ||
} | ||
|
||
componentDidUpdate(prevProps) { | ||
this.initialize(); | ||
} | ||
|
||
componentDidMount() { | ||
this.initialize(); | ||
} | ||
|
||
componentWillUnmount() { | ||
this.destroy(); | ||
} | ||
|
||
destroy() { | ||
} | ||
|
||
createLayers() { | ||
|
||
this._createLayer = true; | ||
var map = this.map; | ||
|
||
let self = this; | ||
this.lineDataSet = new DataSet([]); | ||
this.lineLayer = new baiduMapLayer(map, this.lineDataSet, {}); | ||
|
||
this.pointDataSet = new DataSet([]); | ||
this.pointLayer = new baiduMapLayer(map, this.pointDataSet, {}); | ||
|
||
} | ||
|
||
initialize() { | ||
|
||
var map = this.map = this.props.map; | ||
if (!map) { | ||
return; | ||
} | ||
|
||
if (!this._createLayer) { | ||
this.createLayers(); | ||
} | ||
|
||
this.destroy(); | ||
|
||
var lineData = []; | ||
var pointData = []; | ||
|
||
if (this.props.data) { | ||
this.props.data.forEach((item, index) => { | ||
var fromCenter = item.from.point || utilCityCenter.getCenterByCityName(item.from.name); | ||
var toCenter = item.to.point || utilCityCenter.getCenterByCityName(item.to.name); | ||
var curve = utilCurve.getPoints([fromCenter, toCenter]); | ||
lineData.push({ | ||
geometry: { | ||
type: 'LineString', | ||
coordinates: curve | ||
} | ||
}); | ||
pointData.push({ | ||
geometry: { | ||
type: 'Point', | ||
coordinates: [toCenter.lng, toCenter.lat] | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
this.lineDataSet.set(lineData); | ||
this.lineLayer.update({ | ||
options: { | ||
draw: 'simple', | ||
strokeStyle: '#5E87DB', | ||
lineWidth: 3 | ||
} | ||
}); | ||
|
||
|
||
this.pointDataSet.set(pointData); | ||
this.pointLayer.update({ | ||
options: { | ||
draw: 'simple', | ||
fillStyle: '#5E87DB', | ||
strokeStyle: 'rgba(94,135,219,0.3)', | ||
lineWidth: 5, | ||
size: 5 | ||
} | ||
}); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters