C ++中的跨平台GUI窗口(Cross platform GUI window in C++)
我想知道为什么我已经找不到这个问题了。 如何在C ++中创建跨平台窗口? 通过跨平台,我的意思是支持至少Windows,Mac和Linux。
如果有一个只用于此任务的库,我愿意使用它。 但我不想使用像wxWidgets这样的窗口控件的膨胀库。
我不需要GUI控件,因为我将使用OpenGL。 (出于某种原因,我不想使用像GLUT或GLFW这样的框架。)
I wondered why I couldn't find a question about that already. How can I create a cross-platform window in C++? By cross-platform I mean support for at least Windows, Mac and Linux.
If there is a library for only this task out there I am willing to use that. But I don't want to use a bloated library with window controls like wxWidgets.
I don't need GUI controls because I am going to use OpenGL. (And for some reason I don't want to use frameworks like GLUT or GLFW.)
原文:https://stackoverflow.com/questions/13263537
最满意答案
我看到可能与之相关的错误。 每次遍历for循环中的locations数组时,都会覆盖markersArray。 实例化for循环之外的markersArray。
你能尝试NSLog你想要绘制的每个标记的坐标吗?
如果坐标相同,则标记应该正好在彼此的顶部绘制,使得看起来标记被覆盖,但它们只是在彼此之上。
完成后记录位置和markersArray的计数,以确保它们等于快速检查。
*编辑:我看到你的问题。 每次迭代for循环时,都会覆盖MapView。
尝试这样的事情:
// Create a markersArray property @property (nonatomic, strong) NSMutableArray *markersArray; // Create a GMSMapView property @property (nonatomic, strong) GMSMapView *mapView_; - (void)viewDidLoad { [super viewDidLoad]; [self setupMapView]; [self plotMarkers]; } // Lazy load the getter method - (NSMutableArray *)markersArray { if (!_markersArray) { _markersArray = [NSMutableArray array]; } return _markersArray; } - (void)setupMapView { self.mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera]; self.view = self.mapView_; self.mapView_.myLocationEnabled = YES; self.mapView_.mapType = kGMSTypeHybrid; self.mapView_.settings.myLocationButton = YES; self.mapView_.settings.zoomGestures = YES; self.mapView_.settings.tiltGestures = NO; self.mapView_.settings.rotateGestures = NO; // You also instantiate a GMSCameraPosition class, but you don't add it to your mapview GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:40.0823 longitude:-74.2234 zoom:7]; } - (void)plotMarkers { // I don't know how you're creating your locations array, so I'm just pretending // an array will be returned from this fake method NSArray *locations = [self loadLocations]; for (int i=0; i<[locations count]; i++){ NSString *lat = [[locations objectAtIndex:i] objectAtIndex:0]; NSString *lon = [[locations objectAtIndex:i] objectAtIndex:1]; double lt=[lat doubleValue]; double ln=[lon doubleValue]; NSString *name = [[locations objectAtIndex:i] objectAtIndex:2]; // Instantiate and set the GMSMarker properties GMSMarker *marker = [[GMSMarker alloc] init]; marker.appearAnimation=YES; marker.position = CLLocationCoordinate2DMake(lt,ln); marker.title = name; marker.snippet = [[locations objectAtIndex:i] objectAtIndex:3]; marker.map = self.mapView_; [self.markersArray addObject:marker]; } }
I see something wrong that's possibly related. You're overwriting markersArray every time you iterate through the locations array in the for loop. Instantiate markersArray outside of the for loop.
Could you try to NSLog the coordinates of each marker you're trying to plot?
If the coordinates are the same, the marker should plot right on top of each other making it appear that markers are being overridden, but they're just on top of each other.
Log the count of the locations and markersArray after you're done to make sure they're equal to each as a quick check.
*Edit: I see your problem. You're overriding your MapView every time you iterate through your for loop.
Try something like this:
// Create a markersArray property @property (nonatomic, strong) NSMutableArray *markersArray; // Create a GMSMapView property @property (nonatomic, strong) GMSMapView *mapView_; - (void)viewDidLoad { [super viewDidLoad]; [self setupMapView]; [self plotMarkers]; } // Lazy load the getter method - (NSMutableArray *)markersArray { if (!_markersArray) { _markersArray = [NSMutableArray array]; } return _markersArray; } - (void)setupMapView { self.mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera]; self.view = self.mapView_; self.mapView_.myLocationEnabled = YES; self.mapView_.mapType = kGMSTypeHybrid; self.mapView_.settings.myLocationButton = YES; self.mapView_.settings.zoomGestures = YES; self.mapView_.settings.tiltGestures = NO; self.mapView_.settings.rotateGestures = NO; // You also instantiate a GMSCameraPosition class, but you don't add it to your mapview GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:40.0823 longitude:-74.2234 zoom:7]; } - (void)plotMarkers { // I don't know how you're creating your locations array, so I'm just pretending // an array will be returned from this fake method NSArray *locations = [self loadLocations]; for (int i=0; i<[locations count]; i++){ NSString *lat = [[locations objectAtIndex:i] objectAtIndex:0]; NSString *lon = [[locations objectAtIndex:i] objectAtIndex:1]; double lt=[lat doubleValue]; double ln=[lon doubleValue]; NSString *name = [[locations objectAtIndex:i] objectAtIndex:2]; // Instantiate and set the GMSMarker properties GMSMarker *marker = [[GMSMarker alloc] init]; marker.appearAnimation=YES; marker.position = CLLocationCoordinate2DMake(lt,ln); marker.title = name; marker.snippet = [[locations objectAtIndex:i] objectAtIndex:3]; marker.map = self.mapView_; [self.markersArray addObject:marker]; } }
相关问答
更多-
你可以检查他们的podspecs 。 您可以在密钥源下找到框架的链接。 Google Maps iOS SDK 2.1.1 You can check their podspecs. You can find the link to the framework under the key source. Google Maps iOS SDK 2.1.1
-
基于这里的问题,你可以在下面的for循环的帮助下使用多个标记。 NSArray *arrLatLong; // Get it from your response for(NSDictionary *dictLocation in arrLatLong){ GMSMarker *marker1 = [[GMSMarker alloc] init]; marker1.position = CLLocationCoordinate2DMake(dictLocation[@"latitude" ...
-
我想你一次只能显示一个信息窗口。 另一种方法是使用自定义标记,它包含标记和信息窗口(您需要将自己渲染到标记图像中)。 I think you can only display one info window at a time. An alternative might be to use custom markers, which contain both the marker and the info window (which you'd need to render yourself into th ...
-
iOS Wikitude Google Maps SDK没有清除块上的上下文(iOS Wikitude Google Maps SDK Did not clear context upon block exist)[2022-06-15]
谷歌地图iOS API版本6.1解决了该错误。 我应该感谢Google开发人员为修复和Wikitude开发人员提供论坛帮助。 Wikitude论坛 Google Maps iOS API version 6.1 resolved that bug. I should thank Google developers for fix and Wikitude developers for help on forum. Wikitude forum -
我看到可能与之相关的错误。 每次遍历for循环中的locations数组时,都会覆盖markersArray。 实例化for循环之外的markersArray。 你能尝试NSLog你想要绘制的每个标记的坐标吗? 如果坐标相同,则标记应该正好在彼此的顶部绘制,使得看起来标记被覆盖,但它们只是在彼此之上。 完成后记录位置和markersArray的计数,以确保它们等于快速检查。 *编辑:我看到你的问题。 每次迭代for循环时,都会覆盖MapView。 尝试这样的事情: // Create a markersAr ...
-
GMSAutocompleteViewController是Google Places iOS SDK的一部分。 Places SDK以及Places API Web服务需要安全的https连接。 但是,maps.google.cn域不支持https。 该文件显示: Google Maps Platform产品由域名maps.google.cn在中国境内提供。 此网域不支援https。 向中国的Google Maps Platform产品发出请求时,请将https://maps.googleapis.com ...
-
Google Maps SDK for iOS的地图与Google Map不同(Google Maps SDK for iOS's map is not same as Google Map)[2023-08-20]
我在昨晚测试一个小区域时发现了同样的问题。 细节POI(可能是当MapView的zoomLevel大于16?)在Yours.app和GoogleMaps.app之间是不同的 而且很容易解释:谷歌需要保持核心竞争力。 在地图业务中,数据就是一切。 I found the same problem last night when testing a small area. The detail POIs (maybe when the zoomLevel of MapView is greater than 1 ... -
Google Maps iOS SDK 1.4(几小时前发布)具有以下功能: iOS SDK中的街景视图 Google Maps iOS SDK 1.4 (released a few hours ago) has this feature: Street View in iOS SDK
-
看起来他们听你了! 请查看v1.4的发行说明https://developers.google.com/maps/documentation/ios-sdk/releases#version_140_-_july_2013 It looks like they listened to you! Take a look at the release notes for v1.4 https://developers.google.com/maps/documentation/ios-sdk/releases# ...
-
现在已在最新版本 - 版本1.4.1 - 2013年8 月中修复此问题。请参阅发行说明的已解决问题: 使用数百个GMSMarkers时的性能改进。 This is now fixed in the latest version - Version 1.4.1 - August 2013. See the resolved issues of the release notes: Performance improvements when using hundreds of GMSMarkers.