@@ -609,6 +609,49 @@ var App = (function ($, publ) {
609
609
*/
610
610
publ . setGeocoding = function ( ) {
611
611
612
+ // Hack to add Geocoding buttons to text fields
613
+ // There should be a better way to do this
614
+ if ( $ ( "#issue-form #attributes button.btn-geocode" ) . length == 0 ) {
615
+ $ ( "#issue-form #attributes label:contains('現地住所')" ) . parent ( "p" ) . append (
616
+ '<button name="button" type="button" class="btn-geocode">住所検索</button>'
617
+ ) ;
618
+
619
+ $ ( "button.btn-geocode" ) . on ( "click" , function ( evt ) {
620
+ if ( vector . getSource ( ) . getFeatures ( ) . length > 0 ) {
621
+ var coords = null
622
+ vector . getSource ( ) . getFeatures ( ) . forEach ( function ( feature ) {
623
+ // Todo: only works with point geometries for now for the last geometry
624
+ coords = feature . getGeometry ( ) . getCoordinates ( ) ;
625
+ } ) ;
626
+ coords = ol . proj . transform ( coords , 'EPSG:3857' , 'EPSG:4326' )
627
+ $ . getJSON ( "https://***REMOVED***/reversegeocode/json/" + coords . join ( "," ) + ",1000" , function ( data ) {
628
+ $ ( "#issue-form #attributes label:contains('現地住所')" ) . parent ( "p" ) . children ( "input" ) . val ( data . result . address ) ;
629
+ } ) ;
630
+ }
631
+ } ) ;
632
+
633
+ }
634
+
635
+ if ( $ ( "#issue-form #attributes button.btn-parksearch" ) . length == 0 ) {
636
+ $ ( "#issue-form #attributes label:contains('公園検索')" ) . parent ( "p" ) . append (
637
+ '<button name="button" type="button" class="btn-parksearch">公園検索</button>'
638
+ ) ;
639
+
640
+ $ ( "button.btn-parksearch" ) . on ( "click" , function ( evt ) {
641
+ if ( vector . getSource ( ) . getFeatures ( ) . length > 0 ) {
642
+ var coords = null
643
+ vector . getSource ( ) . getFeatures ( ) . forEach ( function ( feature ) {
644
+ // Todo: only works with point geometries for now for the last geometry
645
+ coords = feature . getGeometry ( ) . getCoordinates ( ) ;
646
+ } ) ;
647
+ coords = ol . proj . transform ( coords , 'EPSG:3857' , 'EPSG:4326' )
648
+ $ . getJSON ( "https://***REMOVED***/reversegeocode/json/" + coords . join ( "," ) + ",1000" , function ( data ) {
649
+ $ ( "#issue-form #attributes label:contains('公園検索')" ) . parent ( "p" ) . children ( "input" ) . val ( data . result . address ) ;
650
+ } ) ;
651
+ }
652
+ } ) ;
653
+ }
654
+
612
655
// Control button
613
656
var geocodingCtrl = new ol . control . Toggle ( {
614
657
html : '<i class="icon-info" ></i>' ,
0 commit comments