@@ -626,18 +626,21 @@ var App = (function ($, publ) {
626
626
*/
627
627
publ . setGeocoding = function ( ) {
628
628
629
+ var default_park_search_field_name = $ ( "input#default_park_search_field_name" ) . val ( )
630
+ var default_geocoder_url = $ ( "input#default_geocoder_url" ) . val ( )
631
+ var default_geocoder_address_field_name = $ ( "input#default_geocoder_address_field_name" ) . val ( )
629
632
// Hack to add Geocoding buttons to text fields
630
633
// There should be a better way to do this
631
634
if ( $ ( "#issue-form #attributes button.btn-geocode" ) . length == 0 ) {
632
- $ ( "#issue-form #attributes label:contains('" + defaults . geocoderAddress + "')" ) . parent ( "p" ) . append (
633
- '<button name="button" type="button" class="btn-geocode">住所検索 </button>'
635
+ $ ( "#issue-form #attributes label:contains('" + default_geocoder_address_field_name + "')" ) . parent ( "p" ) . append (
636
+ '<button name="button" type="button" class="btn-geocode">' + default_geocoder_address_field_name + ' </button>'
634
637
) ;
635
638
636
639
$ ( "button.btn-geocode" ) . on ( "click" , function ( evt ) {
637
640
// Geocode address and add/update icon on map
638
641
if ( $ ( "button.btn-geocode" ) . prev ( "input" ) . val ( ) != "" ) {
639
642
var address = $ ( "button.btn-geocode" ) . prev ( "input" ) . val ( )
640
- $ . getJSON ( "https://***REMOVED*** /geocode/json/" + encodeURIComponent ( address ) , function ( data ) {
643
+ $ . getJSON ( default_geocoder_url + " /geocode/json/" + encodeURIComponent ( address ) , function ( data ) {
641
644
if ( data . result . code >= 0 && data . result . coordinates ) {
642
645
var coords = [ data . result . coordinates . x , data . result . coordinates . y ] ;
643
646
var geom = new ol . geom . Point (
@@ -673,10 +676,10 @@ var App = (function ($, publ) {
673
676
}
674
677
} ) ;
675
678
}
676
-
679
+
677
680
if ( $ ( "#issue-form #attributes button.btn-parksearch" ) . length == 0 ) {
678
- $ ( "#issue-form #attributes label:contains('公園検索' )" ) . parent ( "p" ) . append (
679
- '<button name="button" type="button" class="btn-parksearch">公園検索 </button>'
681
+ $ ( "#issue-form #attributes label:contains(" + default_park_search_field_name + " )") . parent ( "p" ) . append (
682
+ '<button name="button" type="button" class="btn-parksearch">' + default_park_search_field_name + ' </button>'
680
683
) ;
681
684
682
685
$ ( "button.btn-parksearch" ) . on ( "click" , function ( evt ) {
@@ -687,14 +690,30 @@ var App = (function ($, publ) {
687
690
coords = feature . getGeometry ( ) . getCoordinates ( ) ;
688
691
} ) ;
689
692
coords = ol . proj . transform ( coords , 'EPSG:3857' , 'EPSG:4326' )
690
- $ . getJSON ( "https://***REMOVED***/geocoder/service/reversegeocode/json/" + coords . join ( "," ) + ",500?useaddr=true&owner=***REMOVED***&details=true" , function ( data ) {
691
- if ( data . result . address && data . result . details . id ) {
692
- $ ( "#issue-form #attributes label:contains('公園検索')" ) . parent ( "p" ) . children ( "input" ) . val (
693
- "[" + data . result . details . id + "] " + data . result . address
693
+
694
+ $ . getJSON ( default_geocoder_url + "/reversegeocode/json_arr/" + coords . join ( "," ) + ",500?useaddr=true&owner=***REMOVED***&details=true&category=park" , function ( data ) {
695
+ if ( data . length ) {
696
+ $ ( '#ajax-modal' ) . html (
697
+ "<h3 class='title'>Park results </h3>" +
698
+ "<div id='parks'></div>" +
699
+ "<p class='buttons'><input type='submit' value='select' onclick='hideModal(this)'/></p>"
694
700
) ;
695
- }
696
- else {
697
- $ ( "#issue-form #attributes label:contains('公園検索')" ) . parent ( "p" ) . children ( "input" ) . val ( "---" ) ;
701
+ $ ( '#ajax-modal' ) . addClass ( 'park_search_results' ) ;
702
+ data . forEach ( function ( parkData ) {
703
+ if ( parkData . result . address && parkData . result . details . id ) {
704
+ $ ( "div#parks" ) . append ( '<input type="radio" name="parks" value="[' + parkData . result . details . id + ']' + parkData . result . address + '">'
705
+ + parkData . result . address
706
+ + '<br>' )
707
+ }
708
+ } )
709
+ showModal ( 'ajax-modal' , '400px' ) ;
710
+ $ ( "p.buttons input[type='submit']" ) . click ( function ( ) {
711
+ $ ( "#issue-form #attributes label:contains('" + default_park_search_field_name + "')" ) . parent ( "p" ) . children ( "input" ) . val (
712
+ $ ( "div#parks input[type='radio']:checked" ) . val ( )
713
+ ) ;
714
+ } )
715
+ } else {
716
+ $ ( "#issue-form #attributes label:contains('" + default_park_search_field_name + "')" ) . parent ( "p" ) . children ( "input" ) . val ( "---" ) ;
698
717
}
699
718
} ) ;
700
719
}
@@ -885,7 +904,8 @@ var App = (function ($, publ) {
885
904
// Todo: only works with point geometries for now for the last geometry
886
905
var coords = features [ features . length - 1 ] . getGeometry ( ) . getCoordinates ( ) ;
887
906
coords = ol . proj . transform ( coords , 'EPSG:3857' , 'EPSG:4326' )
888
- $ . getJSON ( "https://***REMOVED***/reversegeocode/json/" + coords . join ( "," ) + ",1000" , function ( data ) {
907
+ var default_geocoder_url = $ ( "input#default_geocoder_url" ) . val ( )
908
+ $ . getJSON ( default_geocoder_url + "/reversegeocode/json/" + coords . join ( "," ) + ",1000" , function ( data ) {
889
909
var districtInput = $ ( "#issue-form #attributes label:contains('" + defaults . geocoderDistrict + "')" ) . parent ( "p" ) . children ( "input" ) ;
890
910
var foundDistrict = false ;
891
911
if ( data . result . code >= 0 && data . result . address ) {
0 commit comments