Open seddik opened 4 years ago
@seddik Can you try if overriding formfield template with this changes solves it?
@ -12,7 +12,7 @@
$showLatLng = $showLatLng ? 'true' : 'false';
@endphp
-<div id="coordinates-formfield">
+<div id="coordinates-formfield-{{ $row->field }}">
<coordinates
inline-template
ref="coordinates"
@ -202,6 +202,6 @@
}
});
- var gMapVm = new Vue({ el: '#coordinates-formfield' });
+ var gMapVm = new Vue({ el: '#coordinates-formfield-{{ $row->field }}' });
</script>
@endpush
Or better like this to solve the double inclusion:
@ -12,7 +12,7 @@
$showLatLng = $showLatLng ? 'true' : 'false';
@endphp
-<div id="coordinates-formfield">
+<div id="coordinates-formfield-{{ $row->field }}">
<coordinates
inline-template
ref="coordinates"
@ -107,8 +107,13 @@
},
mounted() {
// Load Google Maps script
+ const apiUrl = 'https://maps.googleapis.com/maps/api/js?key='+this.apiKey+'&callback=gMapVm.$refs.coordinates.initMap&libraries=places';
+ if (document.querySelectorAll('[src="' + apiUrl + '"]').length > 0) {
+ return;
+ }
+
let gMapScript = document.createElement('script');
- gMapScript.setAttribute('src', 'https://maps.googleapis.com/maps/api/js?key='+this.apiKey+'&callback=gMapVm.$refs.coordinates.initMap&libraries=places');
+ gMapScript.setAttribute('src', apiUrl);
document.head.appendChild(gMapScript);
},
methods: {
@ -202,6 +207,6 @@
}
});
- var gMapVm = new Vue({ el: '#coordinates-formfield' });
+ var gMapVm = new Vue({ el: '#coordinates-formfield-{{ $row->field }}' });
</script>
@endpush
@MrCrayon that didn't fix the problem, I've got the upper only, and the lower fields working with it. on the other hand there is no javascript error.
could it be they need a separate gmap initialization function in the URL, by field I mean.
@seddik yes, I think also ref="coordinates"
and wherever is used needs a unique identifier, you can experiment with that until I find the time to check it.
Any news about this problem?
Version information
Description
A clear and concise description of what the bug is.
Steps To Reproduce
Steps to reproduce the behavior:
Expected behavior
I should have two maps and two coords centered in the point set in config/voyager.php
Screenshots
Additional context