my location widget scale problem

2564
16
02-03-2016 07:08 AM
MathiasEriksson
New Contributor II

I have a my location widget that has the code.

{

  "locateButton": {

    "geolocationOptions": {

      "timeout": 15000

    },

    "highlightLocation": true,

    "useTracking": true,

    "scale": 1200

  }

}

the scale command give a perfect scale.

but if I zoom in or out it resets after 15 sekund. ( I can change reset time to what ever I want)

I'm trying to get it to stay at the zoom lvl  the user sets after first positioning. 

If i remove scale is goes to maz zoom every 15 seconds

I have try to use :

{

  "locateButton": {

    "geolocationOptions": {

      "timeout": 15000,

      "setScale": false

    },

    "highlightLocation": true,

    "useTracking": true

  }

}

but the it zooms in to max and stay the. I can't zoom out.

any one have a any good input on this?

0 Kudos
16 Replies
RobertScheitlin__GISP
MVP Emeritus

Mathias Eriksson,

  If you only want the widget to zoom to the defined scale once and then allow the user to change the maps scale as desired from then on then Just add setScale = false in the onLocate function in the widget.js file (line 16):

      onLocate: function(parameters) {
        html.removeClass(this.placehoder, "locating");
        if (this.geoLocate.useTracking) {
          html.addClass(this.placehoder, "tracking");
        }

        if (parameters.error) {
          console.error(parameters.error);
          // new Message({
          //   message: this.nls.failureFinding
          // });
        } else {
          html.addClass(this.domNode, "onCenter");
          this.neverLocate = false;
        }
        this.geoLocate.setScale = false;
      },
0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Mathias Eriksson

   Did this work for you?

0 Kudos
MathiasEriksson
New Contributor II

Have been away from the office. trying today but Can't fint the code exemepl you put in the thred.

I think you mean the Widge.js in folder *\inetpub\wwwroot\WAB13DE\Kalmar\widgets\MyLocation

is that correct ?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Mathias,

   It is in the *\inetpub\wwwroot\WAB13DE\Kalmar\widgets\MyLocation\widget.js file. The onLocate function is what you are looking for.

0 Kudos
MathiasEriksson
New Contributor II

Line 315 . {

        onLocate: function(e) {

            d.removeClass(this.placehoder, "locating");

            this.geoLocate.useTracking && d.addClass(this.placehoder, "tracking");

            e.error ? console.error(e.error) : (d.addClass(this.domNode, "onCenter"), this.neverLocate = !1)}

My don't look like yours.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Mathias,

    That is because you are using the minified code version in that app and not the developer version. That is not an issue though just make it look like this:

onLocate: function(e) {

            d.removeClass(this.placehoder, "locating");

            this.geoLocate.useTracking && d.addClass(this.placehoder, "tracking");

            e.error ? console.error(e.error) : (d.addClass(this.domNode, "onCenter"), this.neverLocate = !1)

            this.geoLocate.setScale = false;}

0 Kudos
MathiasEriksson
New Contributor II

that did onot work so well.

When i add the code line my complete widget disapers.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Mathias,

  Try this then:

onLocate: function(e) {

            this.geoLocate.setScale = 0;

            d.removeClass(this.placehoder, "locating");

            this.geoLocate.useTracking && d.addClass(this.placehoder, "tracking");

            e.error ? console.error(e.error) : (d.addClass(this.domNode, "onCenter"), this.neverLocate = !1)}

0 Kudos
MathiasEriksson
New Contributor II

did not help that either.

app.sandbyborg.se  Here you can se the app online and IO can send the complete code to you if you like to see so I did not make any misstake.

0 Kudos