gpt4 book ai didi

ios - 无法在 MapView 中显示标记

转载 作者:行者123 更新时间:2023-11-28 21:48:54 25 4
gpt4 key购买 nike

我正在使用 RubyMotion 和 MapBox 创建一个应用程序。我想要一个带标记的离线 map 。我可以看到 map ,但看不到标记。这是我的代码:

class MapScreen < PM::Screen

def on_load
RMConfiguration.configuration.setAccessToken("...")

self.view.addSubview(map_view)

annotation = RMPointAnnotation.alloc.initWithMapView(map_view, coordinate: map_view.centerCoordinate, andTitle: 'Hello')
map_view.addAnnotation(annotation)
end

def map_view
return @map_view if @map_view
source = RMMBTilesSource.alloc.initWithTileSetResource('control-room-0.2.0',
ofType:'mbtiles')
@map_view ||= RMMapView.alloc.initWithFrame(self.view.bounds, andTilesource:source).tap do |map|
map.zoom = 2
map.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth
map.setCenterCoordinate(CLLocationCoordinate2D.new(0, 0))
map.showsUserLocation = true
end
end

end

有解决办法吗?

最佳答案

该代码应该可以工作:

class MapScreen < PM::Screen 

def on_load
RMConfiguration.configuration.setAccessToken("...")
self.view.addSubview(map_view)
annotation = RMAnnotation.alloc.initWithMapView(map_view, coordinate: map_view.centerCoordinate, andTitle: 'Hello')
map_view.addAnnotation(annotation)
end

def map_view
return @map_view if @map_view
source = RMMBTilesSource.alloc.initWithTileSetResource('control-room-0.2.0', ofType:'mbtiles')
@map_view ||= RMMapView.alloc.initWithFrame(self.view.bounds, andTilesource:source).tap do |map|
map.zoom = 4
map.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth
map.setCenterCoordinate(CLLocationCoordinate2D.new(0, 0))
map.showsUserLocation = true
map.delegate = self
end
end

def mapView(map_view, layerForAnnotation:annotation)
image = UIImage.imageNamed('list.png')
RMMarker.alloc.initWithUIImage(image)
end

end

关于ios - 无法在 MapView 中显示标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29060036/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com