I have some code that will geocode a point and display it on the map. I would like to label the point with the address.
I create a label graphic using the coordinates of the point and the address, add graphic to the graphics layer, but it does not display on the map.
Not sure what I am missing.
Here is the section of code:
fromlocator.on("location-to-address-complete", function(evt) {
var attr;
if (evt.address.address) {
var fromAddress = evt.address.address;
alert(fromAddress.Address + ", " + fromAddress.City + ", " + fromAddress.Region, ", " + fromAddress.Postal);
if (fromAddress){
document.getElementById("fromAddr").value = fromAddress.Address + ", " + fromAddress.City + ", " + fromAddress.Region, ", " + fromAddress.Postal;
fPoint = new Point(evt.address.location, new SpatialReference({ wkid: 4326 }));
attr = {
"Address": fromAddress
};
fGraphic = new Graphic(fPoint, fromGeocodeSymbol, attr);
graphicsLayer = new GraphicsLayer();
graphicsLayer.add(fGraphic);
mapMain.addLayer(graphicsLayer);
var textColor = new Color("#666");
var textLabel = new TextSymbol(fromAddress)
textLabel.setColor(textColor);
textLabel.font.setSize("14pt");
textLabel.font.setFamily("arial");
textLabelRenderer = new SimpleRenderer(textLabel);
var testlabel = new Graphic(fPoint, textLabel)
mapMain.graphics.add(testlabel);
zoomToAddresses();
getZone(fPoint, "from");
}
}
});