Select to view content in your preferred language

Add a point marker on a map from a click in a ExB custom Widget

199
5
Jump to solution
2 weeks ago
sylvainhotte1
New Contributor II

Hello,

I am builder a custom widget that will be similar as the coordinate widget.

I am still a seed in the ground with ExB widget.

sylvainhotte1_1-1724091094770.png

sylvainhotte1_0-1724090879119.png

 

  1. User click on the cross
  2. then click on the map (a market will appear)
  3. the coordinate are save in variable
  4. then the user click on the button for some function to be executed

Everything is working except for the marker.

I want to be able to add a marker like this when I click on a map I don't know how to make the marker appear. I took inspiration from the coordinate widget. I copied this function into my code to start but...

  const getMarkerGraphic = (mapPoint) => {
    const symbol = new PictureMarkerSymbol({
      url: require('./assets/pin-exb.svg'),
      width: 12,
      height: 22,
      yoffset: 11
    })
    return new Graphic({
      geometry: mapPoint,
      symbol
    })
  }

 

Bu when I reload I get this (failed to load)

sylvainhotte1_2-1724091343893.png

I am stuck there... any creation of any object will give me that problem ( const xyz = new Whatever() )

the function is not event called anywhere in my code at this point.

I coded my widget base on a function model (not a class). But I think the coordinate widget is also a function...

sylvainhotte1_3-1724091599330.png

Any idea ?

Thanks

Sylvain

1 Solution

Accepted Solutions
sylvainhotte1
New Contributor II

I need to add "dependency": "jimu-arcgis" in the manifest

View solution in original post

0 Kudos
5 Replies
sylvainhotte1
New Contributor II

I need to add "dependency": "jimu-arcgis" in the manifest

0 Kudos
Brian_McLeer
Occasional Contributor III

@sylvainhotte1 Would you be willing to share your widget? 

Brian
0 Kudos
sylvainhotte1
New Contributor II

@Brian_McLeerYes no problem. I still have a few things to adjust then I will send it to you. It should be done next week.

Sylvain

sylvainhotte1
New Contributor II

Hello @Brian_McLeer here's the small widget I made.

The widget is called xyurl

sylvainhotte1_0-1724800853905.png

The setting needs a map, the text for the button a url ({x}{y} will be replaced with the actual coordinate one you click on the map) and the color of the pin on the map

sylvainhotte1_1-1724801062891.png

in runtime

(1) click the cross and the the map (the pin will appear)

(2) the you can click the button

(3) click the trash can to delete the pin

sylvainhotte1_2-1724801337627.png

 

This is my first widget, so it may not be perfect.

Hope it help

regards,

Sylvain

Brian_McLeer
Occasional Contributor III

Thank you @sylvainhotte1, I appreciate you being open to sharing it. 

Brian
0 Kudos