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

How to replace/insert the DefaultViewer using the plugin architecture? #1410

Closed
alturium opened this issue Jan 26, 2017 · 9 comments
Closed

Comments

@alturium
Copy link

Hi,
What is the best to use a different and custom Feature Info panel for the Identify plugin, which defaults to the DefaultViewer? There is a property for 'viewer' for Identify but I can't figure out how to best insert my viewer into the state with the current plugin architecture.

One obvious solution is to insert via a custom action/reducer to change the viewer. But when would be the best time to call this action in the setup sequences? Another solution is to create my own Identify plugin, but with the 'viewer' prop it looks like it has designed for to be extended. Plus, I don't want to maintain my own Identify, since there are 35 props being sent to it.

Part of my confusion is the plugin architecture and figuring out how it works.

Thanks ahead of time!

@mbarto
Copy link
Contributor

mbarto commented Jan 26, 2017

Hi,
it's pretty simple:

  • develop your own viewer as a jsx component (e.g. MyViewer.jsx)
  • add a viewer property to localConfig.json, in the Identify plugin cfg section: "viewer": "{context.MyViewer}"
  • add your component in the require section of plugins.js: MyViewer: require('<path to your component>/MyViewer')

You are done.

@alturium
Copy link
Author

I'm still having an issue with the viewer prop is not set.

I've added "viewer": "{context.CustomViewer}" but when evaluated in PluginUtils.js parseExpression() is undefined.

My CustomViewerPlugin.js is being loaded (also added it to localConfig.json).

Here is the localConfig.json ( I copied the "Identify" section from another example ):

{
    "proxyUrl": "/mapstore/proxy/?url=",
    "geoStoreUrl": "/mapstore/rest/geostore",
    "printUrl": "http://demo.geo-solutions.it/geoserver/pdf/info.json",
    "bingApiKey": "AhuXBu7ipR1gNbBfXhtUAyCZ6rkC5PkWpxs2MnMRZ1ZupxQfivjLCch22ozKSCAn",
    "translationsPath": "./MapStore2/web/client/translations",
    "plugins": {
        "desktop": [
            "Map",
            "Toolbar",
            "MousePosition",
            "ScaleBox",
            "BackgroundSwitcher",
            "TOC",
            "CustomViewer",
            {
                "name": "Identify",
                "cfg": {
                    "panelClassName": "modal-dialog info-panel modal-content",
                    "headerClassName": "modal-header",
                    "bodyClassName": "modal-body info-wrap",
                    "asPanel": false,
                    "headerGlyph": "",
                    "glyph": "map-marker",
                    "className": "square-button",
                    "closeGlyph": "1-close",
                    "wrapRevGeocode": true,
                    "enableRevGeocode": true,
                    "viewer": "{context.CustomViewer}",
                    "viewerOptions": {
                        "container": "{context.ReactSwipe}",
                        "header": "{context.SwipeHeader}",
                        "headerOptions": {
                            "useButtons": true
                        },
                        "containerProps": {
                            "continuous": false
                        },
                        "collapsible": true
                    },
                    "excludeOptions": [
                        "links",
                        "allowedSRS",
                        "title",
                        "type",
                        "visibility",
                        "params",
                        "legend",
                        "statistics",
                        "columnDefs",
                        "advancedFilter",
                        "boundingBox",
                        "capabilities",
                        "describeCoverage",
                        "describeLayer",
                        "loading"
                    ]
                }
            }
        ]
    }
}

Thanks!

@alturium
Copy link
Author

Also, how do you change the info_format or format for the buildRequests from 'text/plain' to another value? There is an action changeMapInfoFormat(), but I'm going to guess that this can be configured.

I think I'm almost there with my little custom viewer. Just need to get the 'viewer' prop working and change the map info format.

thanks again!

@mbarto
Copy link
Contributor

mbarto commented Feb 1, 2017

Did you add add your component in the require section of plugins.js: CustomViewer: require('/CustomViewer')?

@mbarto
Copy link
Contributor

mbarto commented Feb 1, 2017

The simplest way to change the default info format is changing appConfig.js, there is an example for mobile mode, you can do the same for the defaultState:

mapInfo: {infoFormat: 'text/html'}

@alturium
Copy link
Author

alturium commented Feb 13, 2017

Hi mbarto,
Sorry for the late response, but got it working!

  • plugin issue solved: i used the plugin (connect version) class when all I needed was a straight up react class. In other words, used the plugin component class vice react class (for my {context.CustomViewer} vice how Identify.jsx is created and used).

  • was able to change the infoFormat to 'application/json' but now I have the problem that the feature info will be different per layer. I will post this as different issue.

thanks for you help!

@MV88
Copy link
Contributor

MV88 commented Feb 13, 2017

Hi @alturium you can send an email to the developers mailing list

Regards,
Matteo

@alturium
Copy link
Author

Hi Matteo,

in regards to ? i'm not sure which issue or what you have in mind.

-Michael

@MV88
Copy link
Contributor

MV88 commented Feb 14, 2017

Hi Michael, I thought you could send an email to the mailing list describing your problem and then we (the Geosolutions team) would open a issue if needed or giving you an answer on the ML. So everyone interested can access it and get the answer.

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

3 participants