Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for WMS Layer support #2568

Merged
merged 13 commits into from
Apr 14, 2019
Merged

Conversation

netmaxt3r
Copy link
Contributor

Does any other open PR do the same thing?

(please answer here)

What issue is this PR fixing?

Add support for WMS Layer from geoserver
https://docs.geoserver.org/latest/en/user/services/wms/reference.html

How did you test this PR?

Tested on iOS simulator and device with Apple Maps and google maps
Android simulator and device samsung galaxy s8

@rborn
Copy link
Collaborator

rborn commented Nov 20, 2018

LGTM (at a first glance) @alvelig 🐽

@shrikantkunte
Copy link

@netmaxt3r I want to use WMSTiles, I referred but it gives errors.
I am using the latest version v0.22.1. I think this version doesn't support WMSTiles. How can I integrate given example in my application? Thanks in advance.

@andrey-shostik
Copy link

andrey-shostik commented Apr 6, 2019

@netmaxt3r @alvelig @rborn Why this PR still is not merged to master?

@rborn
Copy link
Collaborator

rborn commented Apr 8, 2019

@andrey-shostik lack of time and resources, we could use some help in reviewing and testing the PRs 😉

@andrey-shostik
Copy link

andrey-shostik commented Apr 8, 2019

@netmaxt3r
I have tested the example from PR and this works well, and with every layer from demo.geo-solutions.it geoserever too http://prntscr.com/n92brq, but when I change urlTemplate I can't find my Tile on map,
My WMSTile: http://prntscr.com/naet63

<WMSTile
  urlTemplate="https://geoserver-url.com/geoserver/clarity/wms?service=WMS&version=1.1.0&request=GetMap&layers=clarity:LC08_L1TP_148023_20190104_20190130_01_T1_Clarity_compressed&styles=&bbox={minX},{minY},{maxX},{maxY}&width={width}&height={height}&srs=EPSG:4326&format=image/png&transparent=true"
  zIndex={100}
  opacity={0.5}
  tileSize={512}
/>

Also I have tried to set urlTemplate with static coordinates, and after this it looks so: https://prnt.sc/n8z1rq
I suppose that problem is in different EPSG, seems that register of my layer is EPSG:4326, just change it in urlTemplate to EPSG:900913 doesn't help.
How to use EPSG:4326 here?
What do you think?

@christopherdro
Copy link
Collaborator

@netmaxt3r Thank you for this PR. I'd like to get this in for testing. Any chance you can resolve the small merge conflict?

@netmaxt3r
Copy link
Contributor Author

@netmaxt3r
I have tested the example from PR and this works well, and with every layer from demo.geo-solutions.it geoserever too http://prntscr.com/n92brq, but when I change urlTemplate I can't find my Tile on map,
My WMSTile: http://prntscr.com/naet63

<WMSTile
  urlTemplate="https://geoserver-url.com/geoserver/clarity/wms?service=WMS&version=1.1.0&request=GetMap&layers=clarity:LC08_L1TP_148023_20190104_20190130_01_T1_Clarity_compressed&styles=&bbox={minX},{minY},{maxX},{maxY}&width={width}&height={height}&srs=EPSG:4326&format=image/png&transparent=true"
  zIndex={100}
  opacity={0.5}
  tileSize={512}
/>

Also I have tried to set urlTemplate with static coordinates, and after this it looks so: https://prnt.sc/n8z1rq
I suppose that problem is in different EPSG, seems that register of my layer is EPSG:4326, just change it in urlTemplate to EPSG:900913 doesn't help.
How to use EPSG:4326 here?
What do you think?

aha seems like we need to support more spec, we need to implement methods for convert spec boundbox to map bound box. Current implementation for ios and for android is only for EPSG:900913. I am not a wms expert but we can do some research and may be figure out bound box computation, which all specs should we support?

@andrey-shostik
Copy link

andrey-shostik commented Apr 14, 2019

@netmaxt3r Thanks a lot for reply, in my current app we really need support of EPSG:4326.

@christopherdro christopherdro merged commit ce80b43 into react-native-maps:master Apr 14, 2019
@andrey-shostik
Copy link

andrey-shostik commented Apr 15, 2019

@netmaxt3r So could you help in implementation boundbox for EPSG:4326? As I understand we just need to reimplement ios and for android getBoundBox methods? I found the following function for convertation https://gist.github.com/onderaltintas/6649521#file-meters2degress-js can be it helpful? If yes, then how and where it should be used?

@netmaxt3r
Copy link
Contributor Author

I am working on it , will try to complete in two days

@roquie
Copy link

roquie commented Apr 18, 2019

Any news? :)

@netmaxt3r
Copy link
Contributor Author

please check #2821 . I don't have much data to test it please provide your feedback

@andrey-shostik
Copy link

andrey-shostik commented Apr 20, 2019

@netmaxt3r Hello, this is my code https://paste.ofcode.org/3b2KmZ47ks5iYctGxbH4JJ8
As well I have noticed another issue, when on ios I use any wms tile with map provider google tile transparent's doesn't work, and I don't see my map, only wihe background from tile.

@jmruvalcabav
Copy link

jmruvalcabav commented Apr 24, 2019

@andrey-shostik , this is the solution to the issue related to the transparent tile.

in AIRGoogleMapWMSTile:

  • (UIImage *)tileForX:(NSUInteger)x y:(NSUInteger)y zoom:(NSUInteger)zoom
    {
    NSInteger maximumZ = self.maximumZ;
    NSInteger minimumZ = self.minimumZ;
    if(maximumZ && (long)zoom > (long)maximumZ) {
    return nil;
    }
    if(minimumZ && (long)zoom < (long)minimumZ) {
    return nil;
    }
    NSArray *bb = [self getBoundBox:x yAxis:y zoom:zoom];
    NSMutableString *url = [self.template mutableCopy];
    [url replaceOccurrencesOfString: @"{minX}" withString:[NSString stringWithFormat:@"%@", bb[0]] options:0 range:NSMakeRange(0, url.length)];
    [url replaceOccurrencesOfString: @"{minY}" withString:[NSString stringWithFormat:@"%@", bb[1]] options:0 range:NSMakeRange(0, url.length)];
    [url replaceOccurrencesOfString: @"{maxX}" withString:[NSString stringWithFormat:@"%@", bb[2]] options:0 range:NSMakeRange(0, url.length)];
    [url replaceOccurrencesOfString: @"{maxY}" withString:[NSString stringWithFormat:@"%@", bb[3]] options:0 range:NSMakeRange(0, url.length)];
    [url replaceOccurrencesOfString: @"{width}" withString:[NSString stringWithFormat:@"%d", (int)self.tileSize] options:0 range:NSMakeRange(0, url.length)];
    [url replaceOccurrencesOfString: @"{height}" withString:[NSString stringWithFormat:@"%d", (int)self.tileSize] options:0 range:NSMakeRange(0, url.length)];
    NSURL *uri = [NSURL URLWithString:url];
    NSData *data = [NSData dataWithContentsOfURL:uri];
    UIImage *img = [[UIImage alloc] initWithData:data];
    CGSize size = [img size];
    UIGraphicsBeginImageContext(size);
    CGRect rect = CGRectMake(0, 0, size.width, size.height);
    [img drawInRect:rect blendMode:kCGBlendModeNormal alpha:1.0];
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetRGBStrokeColor(context, 0.0, 0.0, 0.0, 0.0);
    CGContextSetLineWidth(context, 5.0);
    CGContextStrokeRect(context, rect);
    UIImage *fixedImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return fixedImage;
    }

@vnlebaoduy
Copy link

vnlebaoduy commented May 14, 2019

@netmaxt3r I cant find WMSTile in version 0.24.2 . How to test this PR. Thank so much

@tunm1228
Copy link

tunm1228 commented May 20, 2019

@netmaxt3r I cant find WMSTile in version 0.24.2 . How to test this PR. Thank so much

I also have problems like you because it has not been updated in the release version.

@sesolaga
Copy link

sesolaga commented Jul 28, 2019

My tile server requires an authentication header to be added to the request:

client.setRequestHeader('Authorization', "Basic " + authorization_encoded);

Is there any place I can add it in the WMSTile ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants