当我通过d3.json作为数据对象加载geojson时,geojson层不显示。但是,如果我将geojson作为URL引用,那么它将正确显示。
我使用的是deck.gl:6.3.2,mapbox-gl:v0.52.0。我正在使用香草javascript。 当我运行此代码时,它不会显示。我检查了“ geomdata”。很好。
d3.json("roads.json", function(geomdata) {
deckgl = new deck.DeckGL({
container,
map: mapboxgl,
mapboxApiAccessToken:
"<myMapBoxKey>,
mapStyle: "mapbox://styles/mapbox/light-v9",
longitude: -98.58,
latitude: 39.82,
zoom: 4,
layers: [
new deck.GeoJsonLayer({
geomdata,
stroked: true,
filled: true,
lineWidthMinPixels: 2,
opacity: 0.4,
getLineColor: [255, 100, 100],
getFillColor: [200, 160, 0, 180]
})
]
});
});
但是,当我在geojson是URL的情况下运行此命令时,它显示得很好。
d3.json("roads.json", function(geomdata) {
var US_MAP_GEOJSON =
"https://raw.githubusercontent.com/uber-common/deck.gl-data/master/examples/highway/roads.json";
deckgl = new deck.DeckGL({
container,
map: mapboxgl,
mapboxApiAccessToken:
"<myMapBoxAccessKey>",
mapStyle: "mapbox://styles/mapbox/light-v9",
longitude: -98.58,
latitude: 39.82,
zoom: 4,
layers: [
new deck.GeoJsonLayer({
data: US_MAP_GEOJSON ,
stroked: true,
filled: true,
lineWidthMinPixels: 2,
opacity: 0.4,
getLineColor: [255, 100, 100],
getFillColor: [200, 160, 0, 180]
})
]
});
});
有任何提示/想法吗? 谢谢
答案 0 :(得分:0)
似乎您必须将一个对象传递到 class PageViewController: UIPageViewController, UIPageViewControllerDelegate, UIPageViewControllerDataSource {
var pageControl = UIPageControl()
// MARK: UIPageViewControllerDataSource
lazy var orderedViewControllers: [UIViewController] = {
return [self.newVc(viewController: "First"),
self.newVc(viewController: "Second"),
self.newVc(viewController: "Third")]
}()
override func viewDidLoad() {
super.viewDidLoad()
self.dataSource = self
self.delegate = self
// This sets up the first view that will show up on our page control
if let firstViewController = orderedViewControllers.first {
setViewControllers([firstViewController],
direction: .forward,
animated: true,
completion: nil)
}
configurePageControl()
// Do any additional setup after loading the view.
}
func configurePageControl() {
// The total number of pages that are available is based on how many available colors we have.
pageControl = UIPageControl(frame: CGRect(x: 0,y: UIScreen.main.bounds.maxY - 50,width: UIScreen.main.bounds.width,height: 50))
self.pageControl.numberOfPages = orderedViewControllers.count
self.pageControl.currentPage = 0
self.pageControl.tintColor = UIColor.black
self.pageControl.pageIndicatorTintColor = UIColor.white
self.pageControl.currentPageIndicatorTintColor = UIColor.black
self.view.addSubview(pageControl)
}
func newVc(viewController: String) -> UIViewController {
return UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: viewController)
}
// MARK: Delegate methords
func pageViewController(_ pageViewController: UIPageViewController, didFinishAnimating finished: Bool, previousViewControllers: [UIViewController], transitionCompleted completed: Bool) {
let pageContentViewController = pageViewController.viewControllers![0]
self.pageControl.currentPage = orderedViewControllers.index(of: pageContentViewController)!
}
// MARK: Data source functions.
func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? {
guard let viewControllerIndex = orderedViewControllers.index(of: viewController) else {
return nil
}
let previousIndex = viewControllerIndex - 1
// User is on the first view controller and swiped left to loop to
// the last view controller.
guard previousIndex >= 0 else {
return orderedViewControllers.last
// Uncommment the line below, remove the line above if you don't want the page control to loop.
// return nil
}
guard orderedViewControllers.count > previousIndex else {
return nil
}
return orderedViewControllers[previousIndex]
}
func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? {
guard let viewControllerIndex = orderedViewControllers.index(of: viewController) else {
return nil
}
let nextIndex = viewControllerIndex + 1
let orderedViewControllersCount = orderedViewControllers.count
// User is on the last view controller and swiped right to loop to
// the first view controller.
guard orderedViewControllersCount != nextIndex else {
return orderedViewControllers.first
// Uncommment the line below, remove the line above if you don't want the page control to loop.
// return nil
}
guard orderedViewControllersCount > nextIndex else {
return nil
}
return orderedViewControllers[nextIndex]
中。但是您的第一个字段不是class RegisterViewController: UIViewController {
var username = ""
var email = ""
var password = ""
var money = ""
var usn = ""
@IBOutlet weak var textUsername: UITextField!
@IBOutlet weak var textEmail: UITextField!
@IBOutlet weak var textPassword: UITextField!
@IBOutlet weak var textMoney: UITextField!
@IBOutlet weak var labelUsername: UILabel!
@IBAction func btnValidate(_ sender: Any) {
username = textUsername.text!
usn = username
email = textEmail.text!
password = textPassword.text!
print (username)
// labelUsername.text = username
// API.register(username: username, email: email, password: password)
}
@IBAction func btnSaveMoney(_ sender: Any) {
money = String(textMoney.text!)
print(money)
print(username)
}
@IBAction func btnBegin(_ sender: Any) {
// API.setMoney(money: money, username: username)
// print(textMoney.text!)
print("your name"+usn)
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
}
*/
组合,而只是一个GeoJsonLayer
。尝试像这样key: value
设置数据。
value