

export const cityIdToName: Record<string, string> = {
  'tap-jinan': '济南市',
  'tap-linyi': '临沂市',
  'tap-weifang': '潍坊市',
  'tap-binzhou': '滨州市',
  'tap-dezhou': '德州市',
  'tap-heze': '菏泽市',
  'tap-jining': '济宁市',
  'tap-dongying': '东营市',
  'tap-qingdao': '青岛市',
  'tap-zibo': '淄博市',
  'tap-yantai': '烟台市',
  'tap-weihai': '威海市',
  'tap-rizhao': '日照市',
  'tap-zaozhuang': '枣庄市',
  'tap-liaocheng': '聊城市',
  'tap-taian': '泰安市'
}

export const nameToCityId :Record<string, string> ={
  '济南市': 'tap-jinan',
  '临沂市': 'tap-linyi',
  '潍坊市': 'tap-weifang',
  '滨州市': 'tap-binzhou',
  '德州市': 'tap-dezhou',
  '菏泽市': 'tap-heze',
  '济宁市': 'tap-jining',
  '东营市': 'tap-dongying',
  '青岛市': 'tap-qingdao',
  '淄博市': 'tap-zibo',
  '烟台市': 'tap-yantai',
  '威海市': 'tap-weihai',
  '日照市': 'tap-rizhao',
  '枣庄市': 'tap-zaozhuang',
  '聊城市': 'tap-liaocheng',
  '泰安市': 'tap-taian',
}

export const addDefs =(svgRef: React.RefObject<SVGSVGElement>)=>{
   // 添加箭头标记定义
      const defs = document.createElementNS('http://www.w3.org/2000/svg', 'defs')
      const marker = document.createElementNS('http://www.w3.org/2000/svg', 'marker')
      marker.id = 'arrowhead'
      marker.setAttribute('markerWidth', '10')
      marker.setAttribute('markerHeight', '10')
      marker.setAttribute('refX', '9')
      marker.setAttribute('refY', '3')
      marker.setAttribute('orient', 'auto')
      const path = document.createElementNS('http://www.w3.org/2000/svg', 'path')
      path.setAttribute('d', 'M0,0 L0,6 L9,3 z')
      path.setAttribute('fill', '#ff6600')
      marker.appendChild(path)
      defs.appendChild(marker)
      svgRef.current?.prepend(defs)

      // 创建渐变定义
      const ldefs = document.createElementNS('http://www.w3.org/2000/svg', 'defs')
      const gradient = document.createElementNS(
        'http://www.w3.org/2000/svg',
        'linearGradient'
      )
      gradient.id = 'jinanGradient'
      gradient.setAttribute('x1', '0%')
      gradient.setAttribute('y1', '0%')
      gradient.setAttribute('x2', '0%')
      gradient.setAttribute('y2', '100%')

      // 添加渐变颜色节点
      const stop1 = document.createElementNS('http://www.w3.org/2000/svg', 'stop')
      stop1.setAttribute('offset', '0%')
      stop1.setAttribute('stop-color', '#21542E')
      const stop2 = document.createElementNS('http://www.w3.org/2000/svg', 'stop')
      stop2.setAttribute('offset', '100%')
      stop2.setAttribute('stop-color', '#bd6f30b6')

      gradient.appendChild(stop1)
      gradient.appendChild(stop2)
      ldefs.appendChild(gradient)
      svgRef.current?.prepend(ldefs)
}
