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

Geomark JS API getGeomarkFeature(url) won't return multi polygons #450

Open
ElocF opened this issue Dec 23, 2024 · 1 comment
Open

Geomark JS API getGeomarkFeature(url) won't return multi polygons #450

ElocF opened this issue Dec 23, 2024 · 1 comment

Comments

@ElocF
Copy link

ElocF commented Dec 23, 2024

Hi, I am trying to use the geomark api for a client to be able to add geomarks to a leaflet web app, so far my code works for single features but when I try and use the example of a multi polygon (https://apps.gov.bc.ca/pub/geomark/geomarks/gm-abcdefghijklmnopqrstuv0bcislands) the geomarkFeature.geometry returns "undefined". I am also pretty new to JS so all of this has been a steep learning curve for me and maybe there is something I am doing wrong or missing for multi geometry features?

`
function getGeomarkFeature(geomarkId) {
var baseUrl = 'https://apps.gov.bc.ca/pub/geomark';
var client = new GeomarkClient(baseUrl);

    client.getGeomarkInfo({
        'geomarkId': geomarkId,
        'callback': function(geomarkInfo) {
        console.log('Geomark Type: ' + geomarkInfo.geometryType);
        console.log('Number of Features: ' + geomarkInfo.numParts);
        console.log('Resource Links: ' + geomarkInfo.resourceLinks);
        }
    })

    client.getGeomarkFeature({
        'geomarkId': geomarkId,
        'srid': 4326,
        'callback': function(geomarkFeature) {
            console.log('Geomark geometry:', geomarkFeature.geometry);
    
            if (geomarkFeature.geometry) {
                try {
                    var wktString = geomarkFeature.geometry.replace(/^SRID=\d+;/, '');
                    console.log('Cleaned WKT String:', wktString);

                    var wicket = new Wkt.Wkt();
                    wicket.read(wktString); //
                    var geojsonFeature = wicket.toJson(); 
                    L.geoJSON(geojsonFeature).addTo(map);
                    map.fitBounds(L.geoJSON(geojsonFeature).getBounds());
                } catch (e) {
                    console.error('Error parsing WKT:', e);
                }
            } else {
                console.error('No geometry found in the Geomark feature.');
            }
        }
    });
}

`

@BK01
Copy link
Collaborator

BK01 commented Jan 10, 2025

Thank you for connecting with us. Would it be possible for you to submit this issue through the following form (Get Help with the Geomark Web Service)?

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

No branches or pull requests

2 participants