AnsweredAssumed Answered

Coordinates issues when I draw a point with a simpleMarker

Question asked by AlexSabrina on Nov 3, 2015
Latest reply on Nov 3, 2015 by AlexSabrina

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>

Outcomes