Select to view content in your preferred language

Mylocation widget max zoom?

4027
16
Jump to solution
12-15-2015 07:10 AM
MathiasEriksson
Deactivated User

I have modifyed mylocation widget to look like this .

{

  "locateButton": {

    "geolocationOptions": {

      "timeout": 150

    },

    "highlightLocation": true,

    "useTracking": true

  }

}

but when i run it get my logation perfect but zoom to a very small area around my position.

it zoom to max in the webapp. arund 1 m fron the gps point is shown.

Can i Sett this to a defult value so it stay at a specefied distans ?

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Mathias,

  OK, I found the issue. in the main config.json you have:

    {
      "uri": "widgets/MyLocation/Widget",
      "position": {
        "left": 7,
        "top": 110,
        "relativeTo": "map"
      },
      "version": "1.4",
      "id": "widgets_MyLocation_Widget_12",
      "name": "MyLocation",
      "label": "Min plats",
      "config": {
        "locateButton": {
          "geolocationOptions": {
            "timeout": 300
          },
          "highlightLocation": true,
          "useTracking": true
        }
      }
    },

and it needs to be:

   {
      "uri": "widgets/MyLocation/Widget",
      "position": {
        "left": 7,
        "top": 110,
        "relativeTo": "map"
      },
      "version": "1.4",
      "id": "widgets_MyLocation_Widget_21",
      "name": "MyLocation",
      "label": "My Location"
    },

The config property is only expecting a path to the json not an actual json object. If the config property is not included then the widget will use the default config.json in the widgets folder.

See your app working properly here:

Work preview of your app

View solution in original post

0 Kudos
16 Replies
RobertScheitlin__GISP
MVP Emeritus

Mathias,

Sure just add the "scale" property to your config object:

{

  "locateButton": {

    "geolocationOptions": {

      "timeout": 150

    },

    "highlightLocation": true,

    "useTracking": true,

    "scale": 1200

  }

}

0 Kudos
MathiasEriksson
Deactivated User

what do scale refer to in this case ?
I don't se any diffrence in scale when I hit the button my location.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Mathias,

   It is the map scale that is used when zooming to found location.

LocateButton | API Reference | ArcGIS API for JavaScript | scale

0 Kudos
MathiasEriksson
Deactivated User

hmmm then change the scale number should give effect in my widget but it does not.

Have copy > Paste your code and still ge a very zoomed in version om my position.
(as close as the basemap let i be approx: 1 meter in in evry direction from my point)

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Mathias,

   Let me do some testing.

RobertScheitlin__GISP
MVP Emeritus

Mathias,

  I tested on one of my live preview site and it woks fine. Try this site an activate the my location button

Preview Site

Here is the json used:

{
  "locateButton": {
    "geolocationOptions": {
      "timeout": 15000
    },
    "highlightLocation": true,
    "scale": 12000,
    "useTracking": true
  }
}

Are you sure you are changing the right file?

[mydeployed app]\configs\MyLocation\config_My Location.json

0 Kudos
MathiasEriksson
Deactivated User

http://www.filedropper.com/mylocation

here you have my widget taken from \wwwroot\WAB13DE\6\widgets

I have change the code in config.jason

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Matias,

  The config.json looks fine als long as you do not have a [mydeployed app]\configs\MyLocation\config_My Location.json which will take precedence over that file.

0 Kudos
MathiasEriksson
Deactivated User

Can't get it to work with scale

This is a complete copy of the map with widget.
http://www.filedropper.com/6_15

Do i miss some config file ?

0 Kudos