Coordinates issues when I draw a point with a simpleMarker

2225
2
Jump to solution
11-03-2015 09:18 AM
AlexGole
Occasional Contributor II

Hi all, I am trying to get coordinates from a point drawn on a map. Just like this sample​, I want users to have the choice of markers by letting them choose their markers using a drop down. The problem is that I can get the coordinates just fine when draw a point (by default) but when I switch marker I cant get the coordinates. Any idea why?

1) Get the coordinates for point drawn:

  var geometry = evt.geometry;
                    var symbol = dom.byId("symbol").value;
                    if (symbol) {
                        symbol = eval(symbol);
                    } else {
                        switch (geometry.type) {
                            case 'point':
                                symbol = tb.markerSymbol;
                                var mp = webMercatorUtils.webMercatorToGeographic(geometry);
                                dom.byId("coordinates").innerHTML = mp.x.toFixed(3) + ", " + mp.y.toFixed(3);
                                break;

2) UI drop down choice:

<div class="form-group">
                    <select class="form-control" id="symbol">
                        <option value="">--- Symbol Options ---</option>
                        <option value="">--- Point ---</option>
                        <option value="new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_SQUARE, 7, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new color([255,0,0]), 1), new color([255,0,0,1]))">Default</option>
                        <option value="new SimpleMarkerSymbol().setColor(new color([0, 0, 255]))">Circle</option>
                        <option value="new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_DIAMOND, 20, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new color([0,0,0]), 1), new color([255,255,0,0.5]))">Diamond</option>
                        <option value="">--- Simple Line ---</option>
                        <option value="new SimpleLineSymbol()">Default</option>
                        <option value="new SimpleLineSymbol(SimpleLineSymbol.STYLE_DASH, new color([255,0,0]), 3)">Dash</option>
                        <option value="new SimpleLineSymbol(SimpleLineSymbol.STYLE_DOT, new color([255,0,0]), 5)">Dot</option>
                        <option value="">--- Cartographic Line Symbols ---</option>
                        <option value="new CartographicLineSymbol()">Default</option>
                        <option value="new CartographicLineSymbol(CartographicLineSymbol.STYLE_SOLID, new color([255,0,0]), 10, CartographicLineSymbol.CAP_ROUND, CartographicLineSymbol.JOIN_ROUND)">Solid, round cap, round join</option>
                        <option value="new CartographicLineSymbol(CartographicLineSymbol.STYLE_SOLID, new color([255,0,0]), 10, CartographicLineSymbol.CAP_SQUARE, CartographicLineSymbol.JOIN_BEVEL)">Solid, square cap, bevel join</option>
                    </select>
                </div>
Tags (1)
0 Kudos
1 Solution

Accepted Solutions
thejuskambi
Occasional Contributor III

Do you mean, the dom.byId("coordinates").innerHTML is not updated. if yes, it is a if else statement, by default the dropdown value will be undefined, so the else part of the code will be executed and when you change that only if part of the code will be executed always. you may need to look into the logic you are trying to implement.

May be move the switch case outside the else part and just set the symbol in the else section.

View solution in original post

2 Replies
thejuskambi
Occasional Contributor III

Do you mean, the dom.byId("coordinates").innerHTML is not updated. if yes, it is a if else statement, by default the dropdown value will be undefined, so the else part of the code will be executed and when you change that only if part of the code will be executed always. you may need to look into the logic you are trying to implement.

May be move the switch case outside the else part and just set the symbol in the else section.

AlexGole
Occasional Contributor II

That was it!

0 Kudos