我正在使用WMSOnGooglemaps sdk作为基本地图。我可以看到我的图层来自geoserver覆盖在谷歌地图上,但我被困在getfeatureinfo请求(我想要点击图层的图层信息)。我在点击图层上的信息,但它是错误的。
//Code to display layer
- (void)loadView
{
GMSTileURLConstructor urls1 = ^(NSUInteger x, NSUInteger y, NSUInteger z)
{
bbox = bboxFromXYZ(x,y,z);
NSString *urlKN1 = [NSString stringWithFormat:@"http://IPADDRESS/geoserver/wms?service=WMS&version=1.1.1&request=GetMap&layers=gidc:plots_category_wise&bbox=%f,%f,%f,%f&width=768&height=1024&srs=EPSG:900913&format=image/png&transparent=true",
bbox.left, bbox.bottom,bbox.right,bbox.top];
return [NSURL URLWithString:urlKN1];
};
GMSTileLayer *tileLayer1 = [GMSURLTileLayer tileLayerWithURLConstructor:urls1];
tileLayer1.map = mapView;
}
- (void)mapView:(GMSMapView *)mapView1 didTapAtCoordinate:(CLLocationCoordinate2D)coordinate
{
CLLocationCoordinate2D position = CLLocationCoordinate2DMake(coordinate.latitude,coordinate.longitude);
NSLog(@"Latitude= %f lonitude = %f",coordinate.latitude,coordinate.longitude);
GMSMarker *marker = [GMSMarker markerWithPosition:position];
point = [mapView1.projection pointForCoordinate:marker.position];
//ankita.dutta@hardcastlegis.com
GMSCoordinateBounds *bounds = [[GMSCoordinateBounds alloc]initWithCoordinate:coordinate coordinate:coordinate];
NSLog(@"Bounds.minx = %f,%f,%f,%f",bounds.southWest.longitude,bounds.northEast.latitude,bounds.northEast.longitude,bounds.southWest.latitude);
NSLog(@"Pointer: %d, %d",[[NSNumber numberWithFloat:point.x] intValue],[[NSNumber numberWithFloat:point.y] intValue] );
GMSVisibleRegion region;
region = mapView.projection.visibleRegion;
GMSCoordinateBounds *bounds1 = [[GMSCoordinateBounds alloc] initWithRegion:region];
NSLog(@"Bounds.minx = %.15f,%.15f,%.15f,%.15f",bounds1.southWest.longitude,bounds1.northEast.latitude,bounds1.northEast.longitude,bounds1.southWest.latitude);
[self getInfo:[[NSNumber numberWithFloat:point.x] intValue] :[[NSNumber numberWithFloat:point.y] intValue] :bounds1.southWest.longitude :bounds1.northEast.latitude :bounds1.northEast.longitude :bounds1.southWest.latitude];
}
-(void)getInfo : (int) xValue : (int) yValue :(double)bboxLMin :(double)bboxLMax :(double)bboxRMin :(double)bboxTMax
{
// [self showLoadingView:YES];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^
{
NSMutableURLRequest * request=[[NSMutableURLRequest alloc]initWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://117.239.80.70:8282/geoserver/wms?service=WMS&version=1.1.1&srs=EPSG:4326&bbox=%.15f,%.15f,%.15f,%.15f&styles=&&buffer=40&info_format=application/json&request=GetFeatureInfo&layers=gidc:plots_category_wise&query_layers=gidc:plots_category_wise&width=%d&height=%d&x=%d&y=%d",bboxLMin,bboxLMax,bboxRMin,bboxTMax, [[NSNumber numberWithFloat:mapView.frame.size.width] intValue],[[NSNumber numberWithFloat:mapView.frame.size.height] intValue],xValue,yValue]]];
NSURLSession * session =[NSURLSession sharedSession];
[[session dataTaskWithRequest:request completionHandler:^(NSData * data, NSURLResponse * response, NSError * error)
{
if (data!=NULL)
{
dispatch_async(dispatch_get_main_queue(), ^
{
//[self showLoadingView:NO];
NSMutableDictionary *listDict=[NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
NSLog(@"Responce =%@",listDict);
NSMutableArray *dataArr = [[listDict valueForKey:@"features"]valueForKey:@"properties"];
[self response:dataArr];
});
}
}]resume];
});
}