Skip to content

Commit 958e4a0

Browse files
committed
add pin to map from address field
1 parent 8f59e0e commit 958e4a0

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

assets/javascripts/app.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,25 @@ var App = (function ($, publ) {
634634
districtInput.val("");
635635
}
636636
});
637+
}else{
638+
// GEOCODE ADDRESS AND ADD ICON TO MAP
639+
if ($("button.btn-geocode").prev("input").val() != ""){
640+
coords = $("button.btn-geocode").prev("input").val()
641+
$.getJSON("https://***REMOVED***/geocode/json/" + coords, function(data) {
642+
if(data.result.coordinates){
643+
var feature = new ol.Feature({
644+
geometry: new ol.geom.Point(
645+
ol.proj.fromLonLat(Object.values(data.result.coordinates), 'EPSG:3857','EPSG:4326')
646+
)
647+
});
648+
vector.getSource().getFeatures().push(feature)
649+
publ.updateForm(vector.getSource().getFeatures());
650+
publ.zoomToExtent();
651+
}
652+
})
653+
}else{
654+
alert("Address is empty!")
655+
}
637656
}
638657
});
639658

0 commit comments

Comments
 (0)