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

only got the map extent, but the layer is always off when i use the share widget. #9

Closed
ERS-Long opened this issue May 6, 2015 · 14 comments

Comments

@ERS-Long
Copy link

ERS-Long commented May 6, 2015

Please let me know what i miss.

Thanks a lot.

Long

@green3g
Copy link
Owner

green3g commented May 7, 2015

@ERS-Long, are you able to provide a live example of this on a public site?

If not, can you provide your config for the widget?

Also, are you using the latest version of the widget?

@ERS-Long
Copy link
Author

ERS-Long commented May 7, 2015

Hi, @roemhildtg:

My site is still in our internal server, so i cannot share it.

but here is the config settings:

        settings: {
            include: true,
            id: 'settings',
            position: 17,
            type: 'titlePane',
            canFloat: true,
            path: 'gis/dijit/AppSettings',
            title: '<i class="icon-large

icon-paper-clip">  Save/Share Current Map',
options: {
//required:
map: true,
layerControlLayerInfos: true,

             //optional (defaults shown):
             appSettings: {},
             parametername: 'cmvSettings',
             mapRightClickMenu: true,
             address: 'email@email.com',
             subject: 'Share Map',
             body: 'Check out this map! <br /> ',
             emailSettings: ['saveMapExtent', 'savelayerVisibility'],
             shareNode: null,
             shareTemplate: '<a href="#"><i class="fa fa-fw

fa-envelope-o">Share Map',
server: null
}
},

Yes, I download the latest widget from the github yesterday.

Thanks a lot,

Long

On Thu, May 7, 2015 at 6:53 AM, roemhildtg notifications@github.com wrote:

@ERS-Long https://github.com/ERS-Long, are you able to provide a live
example of this on a public site?

If not, can you provide your config for the widget?

Also, are you using the latest version of the widget?


Reply to this email directly or view it on GitHub
#9 (comment)
.

@green3g
Copy link
Owner

green3g commented May 8, 2015

Hi @ERS-Long, can you also tell me what types of layers you are using? It would probably be helpful to see your operationalLayers array in your config file. The URL's aren't important so you don't have to include them as they are internal anyways.

@ERS-Long
Copy link
Author

ERS-Long commented May 8, 2015

Hi,
roemhildtg

Thanks a lot.

Here is the layer config portion.

    {
        type: 'dynamic',
        url: '

https://gis.eparm.net/eparmgis/rest/services/R6Secure/RMP_PDO/MapServer',
title: 'R6 RMP Facilities',
options: {
id: 'R6RMPFacilities',
opacity: 1.0,
visible: false,
imageParameters: imageParameters
},
identifyLayerInfos: {
layerIds: [2, 3, 5, 6, 8, 9, 10]
},
layerControlLayerInfos: {
metadataUrl: true
}
},
{
type: 'dynamic',
url: '
https://gis.eparm.net/eparmgis/rest/services/R6Facilities/FRP_R6_Service/MapServer
',
title: 'R6 FRP Facilities',
options: {
id: 'R6FRPFacilities',
opacity: 1.0,
visible: false,
imageParameters: imageParameters
},
identifyLayerInfos: {
layerIds: [0, 1]
},
layerControlLayerInfos: {
metadataUrl: true
}
},
{
type: 'dynamic',
url: '
https://gis.eparm.net/eparmgis/rest/services/R6Secure/Cerclis/MapServer',
title: 'Field Activities',
options: {
id: 'FieldActivities',
opacity: 1.0,
visible: false,
imageParameters: imageParameters
},
identifyLayerInfos: {
layerIds: [0, 1]
},
layerControlLayerInfos: {
metadataUrl: true
}
},

On Thu, May 7, 2015 at 9:30 PM, roemhildtg notifications@github.com wrote:

Hi @ERS-Long https://github.com/ERS-Long, can you also tell me what
types of layers you are using? It would probably be helpful to see your
operationalLayers array in your config file. The URL's aren't important so
you don't have to include them as they are internal anyways.


Reply to this email directly or view it on GitHub
#9 (comment)
.

@green3g
Copy link
Owner

green3g commented May 9, 2015

I just found the bug. I wasn't having any issues, but after pasting the config from the documentation, I experienced the same issue. There was a typo in the documentation config, in the option for emailSettings, savelayerVisibility should be changed to saveLayerVisibility
emailSettings: ['saveMapExtent', 'saveLayerVisibility'],

Good catch!

@ERS-Long
Copy link
Author

Hi, roemhildtg:

Thanks a lot for your help.
Now i moved forward one step, but got a new problem,

it seems the url is too long, but also when i test the url, (it is
something like this

http://wsdtxmal/r6pdo/%3FcmvSettings%3D%257B%2522saveMapExtent%2522%253A%257B%257D%252C%2522saveLayerVisibility%2522%253A%257B%2522R6Removal%2522%253A%257B%2522visible%2522%253Afalse%252C%2522visibleLayers%2522%253A%255B0%252C1%252C2%255D%257D%252C%2522PopulationDensity%2522%253A%257B%2522visible%2522%253Afalse%252C%2522visibleLayers%2522%253A%255B1%252C2%252C3%252C4%255D%257D%252C%2522Quads%2522%253A%257B%2522visible%2522%253Afalse%252C%2522visibleLayers%2522%253A%255B0%252C1%252C2%252C3%255D%257D%252C%2522NatureServe%2522%253A%257B%2522visible%2522%253Afalse%252C%2522visibleLayers%2522%253A%255B5%252C6%252C7%252C8%255D%257D%252C%2522WaterSupply%2522%253A%257B%2522visible%2522%253Afalse%252C%2522visibleLayers%2522%253A%255B0%252C1%252C2%252C3%252C4%255D%257D%252C%2522Transportation-Water%2522%253A%257B%2522visible%2522%253Afalse%252C%2522visibleLayers%2522%253A%255B0%255D%257D%252C%2522Transportation-Ground%2522%253A%257B%2522visible%2522%253Afalse%252C%2522visibleLayers%2522%253A%255B0%252C1%252C2%252C3%255D%257D%252C%2522PublicHealth%2522%253A%257B%2522visible%2522%253Afalse%252C%2522visibleLayers%2522%253A%255B0%255D%257D%252C%2522Government%2522%253A%257B%2522visible%2522%253Afalse%252C%2522visibleLayers%2522%253A%255B-1%255D%257D%252C%2522Energy%2522%253A%257B%2522visible%2522%253Afalse%252C%2522visibleLayers%2522%253A%255B0%252C1%252C2%252C3%252C4%252C5%252C6%255D%257D%252C%2522EmergencyServices%2522%253A%257B%2522visible%2522%253Afalse%252C%2522visibleLayers%2522%253A%255B3%255D%257D%252C%2522Education%2522%253A%257B%2522visible%2522%253Afalse%252C%2522visibleLayers%2522%253A%255B0%252C1%252C2%252C3%252C4%252C5%252C6%252C7%255D%257D%252C%2522Boundaries-Federal%2522%253A%257B%2522visible%2522%253Afalse%252C%2522visibleLayers%2522%253A%255B0%252C1%252C2%252C3%252C4%252C5%255D%257D%252C%2522Boundaries-Urban%2522%253A%257B%2522visible%2522%253Afalse%252C%2522visibleLayers%2522%253A%255B0%252C1%252C2%252C3%252C4%255D%257D%252C%2522EJ_Areas_of_Concern%2522%253A%257B%2522visible%2522%253Afalse%252C%2522visibleLayers%2522%253A%255B0%255D%257D%252C%2522USCG%252FEPA%2520Boundary%2522%253A%257B%2522visible%2522%253Afalse%252C%2522visibleLayers%2522%253A%255B0%252C1%255D%257D%252C%2522WebEOCFeed%2522%253A%257B%2522visible%2522%253Afalse%252C%2522visibleLayers%2522%253A%255B0%255D%257D%252C%2522FieldActivities%2522%253A%257B%2522visible%2522%253Afalse%252C%2522visibleLayers%2522%253A%255B0%255D%257D%252C%2522R6FRPFacilities%2522%253A%257B%2522visible%2522%253Afalse%252C%2522visibleLayers%2522%253A%255B0%255D%257D%252C%2522R6RMPFacilities%2522%253A%257B%2522visible%2522%253Afalse%252C%2522visibleLayers%2522%253A%255B2%252C3%252C5%252C6%252C8%252C9%252C10%252C11%255D%257D%252C%2522R6EPAFacilities%2522%253A%257B%2522visible%2522%253Atrue%252C%2522visibleLayers%2522%253A%255B0%252C1%252C2%252C3%252C4%252C5%252C6%255D%257D%257D%257D

when i test it, i got

HTTP Error 400. The request URL is invalid.

Please see if you know the issue in this regard.

Thank you again so much for your help.

On Sat, May 9, 2015 at 2:39 PM, roemhildtg notifications@github.com wrote:

I just found the bug. I wasn't having any issues, but after pasting the
config from the documentation, I experienced the same issue. There was a
typo in the documentation config, in the option for emailSettings,
savelayerVisibility should be changed to save_L_ayerVisibility
emailSettings: ['saveMapExtent', 'saveLayerVisibility'],

Good catch!


Reply to this email directly or view it on GitHub
#9 (comment)
.

@green3g
Copy link
Owner

green3g commented May 10, 2015

I ran into this issue as well, we are using this widget to save drawings which end up to be 20,000 characters or more... I ended up writing two php scripts to store and retrieve the saved map in a sqlite database. To use it, place the php script on your server somewhere, and then send the option server: 'path/to/index.php' to appSettings.

Note: you have to have php installed and enabled on your server for this.

@ERS-Long
Copy link
Author

Thanks a lot. Got the php/sqlite in place, and the link is working. I will
do more test this coming week.

One thing i noticed is if I clear the google chrome history data, then it
seems to me it also deletes the sqlite DB content? i am not very sure about
that, but will do more test.

Another thing is the php page does need write permission in the web server
folder, is there anyway we can control that or change that?

Anyway that is a wonder approach, thank you very much!

Long

On Sun, May 10, 2015 at 9:36 AM, roemhildtg notifications@github.com
wrote:

I ran into this issue as well. I ended up writing two php scripts
https://github.com/roemhildtg/CMV_Widgets/blob/master/widgets/AppSettings/php/index.php
to store and retrieve the saved map in a sqlite database. To use it, place
the php script on your server somewhere, and then send the option server:
'path/to/index.php' to appSettings.


Reply to this email directly or view it on GitHub
#9 (comment)
.

@ERS-Long
Copy link
Author

Hi, @roemhildtg

It works beautifully in my test environment.

The only thing or enhancement I would like to have if you could is to store
the basemap info in the configure setting. Please let me know if that is in
this version or it is something for future enhancement.

Thanks again.

On Sun, May 10, 2015 at 9:09 PM, Long Ma long.d.ma@gmail.com wrote:

Thanks a lot. Got the php/sqlite in place, and the link is working. I will
do more test this coming week.

One thing i noticed is if I clear the google chrome history data, then it
seems to me it also deletes the sqlite DB content? i am not very sure about
that, but will do more test.

Another thing is the php page does need write permission in the web server
folder, is there anyway we can control that or change that?

Anyway that is a wonder approach, thank you very much!

Long

On Sun, May 10, 2015 at 9:36 AM, roemhildtg notifications@github.com
wrote:

I ran into this issue as well. I ended up writing two php scripts
https://github.com/roemhildtg/CMV_Widgets/blob/master/widgets/AppSettings/php/index.php
to store and retrieve the saved map in a sqlite database. To use it, place
the php script on your server somewhere, and then send the option server:
'path/to/index.php' to appSettings.


Reply to this email directly or view it on GitHub
#9 (comment)
.

@green3g
Copy link
Owner

green3g commented May 11, 2015

It's not in this version ootb, but it is easily doable. Just modify the basemap widget to store and retrieve the settings using dojo/topic. See the details here

We did it like this:

define([
    'dojo/_base/declare',
    'dijit/_WidgetBase',
    'dijit/_TemplatedMixin',
    'dijit/_WidgetsInTemplateMixin',
    'dojo/_base/lang',
    'dijit/DropDownMenu',
    'dijit/MenuItem',
    'dojo/_base/array',
    'dojox/lang/functional',
    'dojo/text!./Basemaps/templates/Basemaps.html',
    'esri/dijit/BasemapGallery',
    'dojo/topic',
    'dojo/i18n!./Basemaps/nls/resource',
    'dijit/form/DropDownButton',
    'xstyle/css!./Basemaps/css/Basemaps.css'
], function (declare, _WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin, lang, DropDownMenu, MenuItem, array, functional, template, BasemapGallery, topic, i18n) {

    // main basemap widget
    return declare([_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin], {
        templateString: template,
        widgetsInTemplate: true,
        i18n: i18n,
        mode: 'agol',
        title: i18n.title,
        //baseClass: 'gis_Basemaps_Dijit',
        //buttonClass: 'gis_Basemaps_Button',
        //menuClass: 'gis_Basemaps_Menu',
        mapStartBasemap: 'streets',
        basemapsToShow: ['streets', 'satellite', 'hybrid', 'topo', 'gray', 'oceans', 'national-geographic', 'osm'],
        validBasemaps: [],
        selectedIcon: 'fa fa-fw fa-check-square-o',
        emptyIcon: 'fa fa-fw fa-square-o',
        postCreate: function () {
            this.inherited(arguments);
            //this.currentBasemap = this.mapStartBasemap || null;

            if (this.mode === 'custom') {
                this.gallery = new BasemapGallery({
                    map: this.map,
                    showArcGISBasemaps: false,
                    basemaps: functional.map(this.basemaps, function (map) {
                        return map.basemap;
                    })
                });
                // if (this.map.getBasemap() !== this.mapStartBasemap) { //based off the title of custom basemaps in viewer.js config
                //     this.gallery.select(this.mapStartBasemap);
                // }
                this.gallery.startup();
            }

            this.menu = new DropDownMenu({
                style: 'display: none;' //,
                        //baseClass: this.menuClass
            });

            array.forEach(this.basemapsToShow, function (basemap) {
                if (this.basemaps.hasOwnProperty(basemap)) {
                    var menuItem = new MenuItem({
                        id: basemap,
                        label: this.basemaps[basemap].title,
                        iconClass: 'fa fa-fw ' + this.emptyIcon,
                        onClick: lang.hitch(this, function () {
                            if (basemap !== this.currentBasemap) {
                                /* save the current basemap value */
                                topic.publish('AppSettings/setValue', 'saveBasemap', {
                                    value: basemap
                                });
                                topic.publish('googleAnalytics/events', {
                                    category: 'Basemap',
                                    action: 'basemap-change',
                                    label: basemap
                                });
                                this.setBasemap(basemap);
                            }
                        })
                    });
                    this.menu.addChild(menuItem);
                }
            }, this);

            this.dropDownButton.set('dropDown', this.menu);

            /* load the saved basemap value */
            topic.subscribe('AppSettings/onSettingsLoad', lang.hitch(this, '_loadBasemapFromSettings'));

        },
        setBasemap: function (basemap) {
            if (this.currentBasemap !== basemap) {
                this.currentBasemap = basemap;
                if (this.mode === 'custom') {
                    this.gallery.select(basemap);
                } else {
                    this.map.setBasemap(basemap);
                }
                var ch = this.menu.getChildren();
                array.forEach(ch, lang.hitch(this, function (c) {
                    if (c.id === basemap) {
                        c.set('iconClass',  this.selectedIcon);
                    } else {
                        c.set('iconClass',  this.emptyIcon);
                    }
                }));
            }
        },
        startup: function () {
            this.inherited(arguments);
            this.setBasemap(this.mapStartBasemap);
        },
        _loadBasemapFromSettings: function (settings) {
            if (settings && settings.saveBasemap &&
                    settings.saveBasemap.value &&
                    (settings.saveBasemap.save || settings.saveBasemap.urlLoad)) {
                this.setBasemap(settings.saveBasemap.value);
            }
        }
    });
});

@green3g
Copy link
Owner

green3g commented May 11, 2015

I'm also working on making the widget easier to use with mixins, and I've started on that but I've got a little more work to do. I'll probably push that out tomorrow, then a mixin could be created to add the basemap settings into the widget.

@ERS-Long
Copy link
Author

Hi, Gregg:

Thank you so much, got it working now.

Added this in the config part

                 //optional (defaults shown):
                 appSettings: {
                    saveBasemap: {
                        save: false,
                        value: {},
                        checkbox: true,
                        label: 'Save Basemap',
                        urlLoad: false
                    }
                 },


                 emailSettings: ['saveMapExtent',

'saveLayerVisibility', 'saveBasemap'],

everything works wonderfully!!

Thanks again.

Long

On Mon, May 11, 2015 at 4:00 PM, Gregg Roemhildt notifications@github.com
wrote:

I'm also working on making the widget easier to use with mixins, and I've
started on that but I've got a little more work to do. I'll probably push
that out tomorrow, then a mixin could be created to add the basemap
settings into the widget.


Reply to this email directly or view it on GitHub
#9 (comment)
.

@green3g
Copy link
Owner

green3g commented May 12, 2015

Just a small warning on the php script, it's not sanitizing any of the input so be wary of placing it on a public facing server. Someone could easily post something like 'DROP * FROM Data WHERE 1=1;'..in addition to sql commands, there may be other security flaws.

@ERS-Long
Copy link
Author

Ok, I am aware of that, it should not be that critical, the lost maybe just
the saved map settings.

Thanks.

On Mon, May 11, 2015 at 8:11 PM, Gregg Roemhildt notifications@github.com
wrote:

Just a small warning on the php script, it's not sanitizing any of the
input so be wary of placing it on a public facing server. Someone could
easily post something like 'DROP * FROM Data WHERE 1=1;'..in addition to
sql commands, there may be other security flaws.


Reply to this email directly or view it on GitHub
#9 (comment)
.

@green3g green3g closed this as completed May 28, 2015
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