我在使用 SKMaps for iOS 时遇到问题。它似乎没有加载注释。它应该在湖周围某处显示注释
同样在初始化时,它不会去指定的区域。
初始化映射方法
-(void) initMap {
/*
self.mapView = [[SKMapView alloc] initWithFrame:CGRectMake(0.0f, 0.0f,
CGRectGetWidth(self.view.frame), CGRectGetHeight(self.view.frame))];
*/
self.mapView = [[SKMapView alloc] initWithFrame:
CGRectMake(0.0f, 0.0f, 238.0f, 157.0f)];
self.mapView.autoresizingMask
= UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
// set initial coordinates
// la mesa dam
//_loc2DLamesaDam = CLLocationCoordinate2DMake(14.7241845,121.085998);
SKCoordinateRegion region;
region.center = CLLocationCoordinate2DMake(14.7241845,121.085998);
region.zoomLevel = 17;
self.mapView.visibleRegion = region;
//[self.view addSubview:mapView];
//show the compass
self.mapView.settings.showCompass = YES;
//hide the map scale
self.mapView.mapScaleView.hidden = YES;
self.mapView.settings.rotationEnabled = NO;
self.mapView.settings.followUserPosition = YES;
SKMapZoomLimits zoomLimits;
zoomLimits.mapZoomLimitMax = 17;
zoomLimits.mapZoomLimitMin = 10;
self.mapView.settings.zoomLimits = zoomLimits;
self.mapView.settings.headingMode = SKHeadingModeRotatingMap;
[self determineMapStyle];
[self addAnotation:CLLocationCoordinate2DMake(14.7241845,121.085998)
annotationId:1
imageName:nil
imageHeight:0.0f
imageWidth:0.0f
skAnotationType:SKAnnotationTypePurple];
}
添加注释方法
-(void)addAnotation:(CLLocationCoordinate2D) coordinate annotationId:(int) annotationId
imageName:(NSString*)imageName imageHeight:(float) imageHeight imageWidth:(float)
imageWidth skAnotationType:(SKAnnotationType) skAnotationType {
[mapView removeAnnotationWithID:annotationId];
SKAnnotation *annotation = [SKAnnotation annotation];
annotation.identifier = annotationId;
annotation.location = coordinate; //CLLocationCoordinate2DMake(52.5237, 13.4137);
SKAnimationSettings *animationSettings = [SKAnimationSettings animationSettings];
if(imageName.length==0 || imageName == (id)[NSNull null])
{
annotation.annotationType = skAnotationType;
} else {
//Annotation with view
//create our view
UIImageView *coloredView = [[UIImageView alloc] initWithFrame:
CGRectMake(0.0, 0.0, 128.0, 128.0)];
coloredView.image = [UIImage imageNamed:imageName];
//create the SKAnnotationView
SKAnnotationView *view = [[SKAnnotationView alloc] initWithView:coloredView
reuseIdentifier:@"viewID"];
//set the custom view
annotation.annotationView = view;
}
[self.mapView addAnnotation:annotation withAnimationSettings:animationSettings];
//[mapView addAnnotation:viewAnnotation withAnimationSettings:animationSettings];}
最佳答案
设置可见区域有效,以及添加带有自定义 View 的注释。这是在我们的演示项目中工作的代码:
UIImageView *customAnnotationView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];
customAnnotationView.backgroundColor = [UIColor greenColor];
customAnnotationView.image = [UIImage imageNamed:@"santa"]; //"santa.png" was added to resources
SKAnnotationView *annotationView = [[SKAnnotationView alloc] initWithView:customAnnotationView reuseIdentifier:@"reusableIdentifier"];
SKAnnotation *annotation = [SKAnnotation annotation];
annotation.identifier = 123456;
annotation.location = region.center;
annotation.annotationView = annotationView;
[self.mapView addAnnotation:annotation withAnimationSettings:[SKAnimationSettings animationSettings]];
关于iOS SKMaps 不加载注释(Xcode 6,Objective C),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33408772/
鉴于我有以下迁移:Sequel.migrationdoupdoalter_table:usersdoadd_column:is_admin,:default=>falseend#SequelrunsaDESCRIBEtablestatement,whenthemodelisloaded.#Atthispoint,itdoesnotknowthatusershaveais_adminflag.#Soitfails.@user=User.find(:email=>"admin@fancy-startup.example")@user.is_admin=true@user.save!ende
我实际上是在尝试使用RVM在我的OSX10.7.5上更新ruby,并在输入以下命令后:rvminstallruby我得到了以下回复:Searchingforbinaryrubies,thismighttakesometime.Checkingrequirementsforosx.Installingrequirementsforosx.Updatingsystem.......Errorrunning'requirements_osx_brew_update_systemruby-2.0.0-p247',pleaseread/Users/username/.rvm/log/138121
我收到这个错误:RuntimeError(自动加载常量Apps时检测到循环依赖当我使用多线程时。下面是我的代码。为什么会这样?我尝试多线程的原因是因为我正在编写一个HTML抓取应用程序。对Nokogiri::HTML(open())的调用是一个同步阻塞调用,需要1秒才能返回,我有100,000多个页面要访问,所以我试图运行多个线程来解决这个问题。有更好的方法吗?classToolsController0)app.website=array.join(',')putsapp.websiteelseapp.website="NONE"endapp.saveapps=Apps.order("
我一直致力于让我们的Rails2.3.8应用程序在JRuby下正确运行。一切正常,直到我启用config.threadsafe!以实现JRuby提供的并发性。这导致lib/中的模块和类不再自动加载。使用config.threadsafe!启用:$rubyscript/runner-eproduction'pSim::Sim200Provisioner'/Users/amchale/.rvm/gems/jruby-1.5.1@web-services/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:105:in`co
我们目前正在为ROR3.2开发自定义cms引擎。在这个过程中,我们希望成为我们的rails应用程序中的一等公民的几个类类型起源,这意味着它们应该驻留在应用程序的app文件夹下,它是插件。目前我们有以下类型:数据源数据类型查看我在app文件夹下创建了多个目录来保存这些:应用/数据源应用/数据类型应用/View更多类型将随之而来,我有点担心应用程序文件夹被这么多目录污染。因此,我想将它们移动到一个子目录/模块中,该子目录/模块包含cms定义的所有类型。所有类都应位于MyCms命名空间内,目录布局应如下所示:应用程序/my_cms/data_source应用程序/my_cms/data_ty
关闭。这个问题是opinion-based.它目前不接受答案。想要改进这个问题?更新问题,以便editingthispost可以用事实和引用来回答它.关闭5年前。Improvethisquestion我审查了一些用Ruby编写的专业代码,没有发现任何评论。代码读起来相当清晰,但没有self记录。我应该期望专业编写的Ruby代码有注释吗?或者,是否有一些Ruby原则认为注释不是必需的?
如何只加载map边界内的标记gmaps4rails?当然,在平移和/或缩放后加载新的。与此直接相关的是,如何获取map的当前边界和缩放级别? 最佳答案 我是这样做的,我只在用户完成平移或缩放后替换标记,如果您需要不同的行为,请使用不同的事件监听器:在你看来(index.html.erb):{"zoom"=>15,"auto_adjust"=>false,"detect_location"=>true,"center_on_user"=>true}},false,true)%>在View的底部添加:functiongmaps4rail
我需要做这样的事情classUser'User',:foreign_key=>'abuser_id'belongs_to:gameendclassGame['JOINabuse_reportsONusers.id=abuse_reports.abuser_id','JOINgamesONgames.id=abuse_reports.game_id'],:group=>'users.id',:select=>'users.*,count(distinctgames.id)ASgame_count,count(abuse_reports.id)asabuse_report_count',:
我指的是pubrailscasttutorial并已正确执行所有步骤,但在运行最后一个命令时,即rackupprivate_pub.ru-sthin-Eproduction为了架设faye服务器,我收到以下错误:/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in`require':cannotloadsuchfile--thin(LoadError)from/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in`require'from/var/lib/gems/1.9.1/gems
我们在服务器端遇到libxml-rubygem的问题可能是因为它使用x86_64架构:$uname-aLinuxip-10-228-171-642.6.21.7-2.fc8xen-ec2-v1.0#1SMPTueSep110:25:30EDT2009x86_64GNU/Linuxrequire'libxml'LoadError:/usr/local/ruby-enterprise/lib/ruby/gems/1.8/gems/libxml-ruby-1.1.4/lib/libxml_ruby.so:invalidELFheader-/usr/local/ruby-enterprise/