export default class ADayMapAndroid extends Component {
constructor (props) {
super(props)
this.state = {
allAxis: this.props.oneDayData
}
this.uluru = this.state.allAxis[0]
this.axisArray = []
this.markerInfoArray = []
for (let i = 0; i
if (this.state.allAxis[i].type !== 'flight' &&
this.state.allAxis[i].type !== 'line' &&
this.state.allAxis[i].type !== 'tip' &&
this.state.allAxis[i].type !== 'roadtrip') {
let temp = {lat: parseFloat(this.state.allAxis[i].axis[0]), lng: parseFloat(this.state.allAxis[i].axis[1])}
this.axisArray.push(temp)
let tempMarker = this.state.allAxis[i]
if (!this.state.allAxis[i].address) {
tempMarker.address = ''
} else {
tempMarker.address = '
' + '地址:' + this.state.allAxis[i].address + '
'
}
this.markerInfoArray.push(tempMarker)
}
}
}
componentDidMount () {
// console.log(JSON.stringify(this.axisArray))
this.webview.injectJavascript(`
var labels = ['1','2','3','4','5','6','7','8','9','10','11','12','13','14','15'];
var icOnBase= 'https://uniqueway-document.b0.upaiyun.com/app/uniqueway/newplaceIcon.png';
function initMap() {
var uluru = ${JSON.stringify(this.axisArray[0])};
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 4,
center: uluru,
disableDefaultUI: true,
zoomControl: true
});
var bounds = new google.maps.LatLngBounds ();
var markArr = [];
${JSON.stringify(this.axisArray)}.forEach(function(feature,i) {
var marker = new google.maps.Marker({
position: feature,
map: map,
label: {
text: labels[i % labels.length],
color: 'white'
},
icon: iconBase
});
bounds.extend (feature);
markArr.push(marker);
});
map.fitBounds (bounds);
var flightPath = new google.maps.Polyline({
path: ${JSON.stringify(this.axisArray)},
geodesic: true,
strokeColor: '#2eb872',
strokeOpacity: 1.0,
strokeWeight: 2
});
flightPath.setMap(map);
for (let i = 0; i
let infowindow = new google.maps.InfoWindow({
content: '
'+ '时间:' + ${JSON.stringify(this.markerInfoArray)}[i].start_time + '-' + ${JSON.stringify(this.markerInfoArray)}[i].end_time + '
' +
'
'+ '名称:' + ${JSON.stringify(this.markerInfoArray)}[i].name + '
' +
${JSON.stringify(this.markerInfoArray)}[i].address
});
markArr[i].addListener('click', function() {
infowindow.open(map, markArr[i]);
});
}
}
`)
}
render () {
return (