Select to view content in your preferred language

How do I create bookmarks (in the javascript code) using point and scale (rather than extent)?

1267
2
Jump to solution
12-09-2021 08:09 PM
WWUMap
by
Emerging Contributor

Hi,

I'm using the Bookmarks widget, preloading bookmarks in the JavaScript code.
It works fine using type: extent:

new Bookmark({
name: "Test1",
viewpoint: {
targetGeometry: {
type: "extent",
xmin: -122.486,
ymin: 48.738,
xmax: -122.484,
ymax: 48.739
} } }),

 

But the scale isn't working for type: point:

new Bookmark({
name: "Test2",
viewpoint: {
targetGeometry: {
type: "point", 
longitude: -122.488,
latitude: 48.73,
scale: ???
} } }),
    

How do I specify / use the scale parameter?

thanks,

~stefan (javascript beginner)

0 Kudos
1 Solution

Accepted Solutions
LaurenBoyd
Esri Contributor

Hi Stefan,

The scale property needs to be set on the Viewpoint, not on the target geometry. See the example below:

const bookmark = new Bookmark({
    name: "Test",
    viewpoint: {
        scale: 1600,
        targetGeometry: {
            type: "point",
            longitude: -122.488,
            latitude: 48.73
        }
    }
});

 The following sample shows this same code in action on lines 55-66: https://codepen.io/laurenb14/pen/JjrEYmO?editors=1000

Hope that helps!

-Lauren

Lauren

View solution in original post

0 Kudos
2 Replies
LaurenBoyd
Esri Contributor

Hi Stefan,

The scale property needs to be set on the Viewpoint, not on the target geometry. See the example below:

const bookmark = new Bookmark({
    name: "Test",
    viewpoint: {
        scale: 1600,
        targetGeometry: {
            type: "point",
            longitude: -122.488,
            latitude: 48.73
        }
    }
});

 The following sample shows this same code in action on lines 55-66: https://codepen.io/laurenb14/pen/JjrEYmO?editors=1000

Hope that helps!

-Lauren

Lauren
0 Kudos
WWUMap
by
Emerging Contributor

Thanks LaurenBoyd - exactly what I was looking for!

0 Kudos