- 22
- 0
import React from 'react';import * as d3 from "d3";class Map extends React.Component { constructor(props){ super(props); this.Map=React.createRef(); } componentDidMount(){ this.draw(); } handleChangeMap=(provinceName)=>{ this.props.handleChangeMap(provinceName); } draw=()=>{ let svg1=this.Map.current; let svg = d3.select(svg1); const width = +svg.attr('width'); const height = +svg.attr('height'); const margin = {top: 200, right: 200, bottom: 100, left: 200}; const innerWidth = width - margin.left - margin.right; const innerHeight = height - margin.top - margin.bottom; const g = svg.append('g').attr('id', 'maingroup') .attr('transform', `translate(${margin.left}, ${margin.top})`); const projection = d3.geoMercator() .scale(200) .translate([innerWidth/2,innerHeight/2]); const pathGenerator = d3.geoPath().projection(projection); d3.json('./china.json').then( function(data){ console.log(data); // this code is really important if you want to fit your geoPaths (map) in your SVG element; } ); } render(){ return( <svg width="1600" height="800" id="mainsvg" ref={this.Map}></svg> ) }}export default Map;代码如上图,代码排查后发现是使用d3.json函数出错,出错内容为Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0。查了很久官网了,望各位大佬指点我一下
0
打赏
收藏
点击回答
网站公告
- 扫一扫访问手机版
回答动态

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器更新之后。服务器里面有部分玩家要重新创建角色是怎么回事啊?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题函数计算不同地域的是不能用内网吧?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题ARMS可以创建多个应用嘛?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题在ARMS如何申请加入公测呀?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题前端小程序接入这个arms具体是如何接入监控的,这个init方法在哪里进行添加?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器刚到期,是不是就不能再导出存档了呢?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器的游戏版本不兼容 尝试更新怎么解决?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器服务器升级以后 就链接不上了,怎么办?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器转移以后服务器进不去了,怎么解决?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器修改参数后游戏进入不了,是什么情况?预计能赚取 0积分收益
- 回到顶部
- 回到顶部
