summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIndoteknik . <it@fixcomart.co.id>2025-06-14 11:49:33 +0700
committerIndoteknik . <it@fixcomart.co.id>2025-06-14 11:49:33 +0700
commit60801084c9c93b3ec2d584a8a1de4af019b5fa80 (patch)
tree96688f6ff3b87b4380753d113cc0a148e9d4ee92
parent1cecf60302ea02e250a97ca2dbc6679332988bc0 (diff)
(andri) fix peletakan search autocomplete & tambahan info mengenai address map
-rw-r--r--ab_openstreetmap/static/src/js/googlemap_widget.js62
-rw-r--r--indoteknik_custom/models/res_partner.py2
2 files changed, 38 insertions, 26 deletions
diff --git a/ab_openstreetmap/static/src/js/googlemap_widget.js b/ab_openstreetmap/static/src/js/googlemap_widget.js
index ebbffa1d..e13fac61 100644
--- a/ab_openstreetmap/static/src/js/googlemap_widget.js
+++ b/ab_openstreetmap/static/src/js/googlemap_widget.js
@@ -53,6 +53,8 @@ odoo.define("ab_openstreetmap.googlemap_widget", function (require) {
const mapEl = document.getElementById("mapid");
if (!mapEl) return;
+ mapEl.style.position = "relative";
+
const { Map } = await google.maps.importLibrary("maps");
const { AdvancedMarkerElement } = await google.maps.importLibrary("marker");
@@ -72,44 +74,54 @@ odoo.define("ab_openstreetmap.googlemap_widget", function (require) {
if (edit) {
marker.addListener("dragend", () => {
const pos = marker.position;
- this.trigger_up("field_changed", {
- dataPointID: this.dataPointID,
- changes: {
- latitude: pos.lat.toString(),
- longtitude: pos.lng.toString(),
- },
- viewType: this.viewType,
- });
+ this._updateCoordinates(pos.lat, pos.lng);
});
- // Search Box (autocomplete)
+ // Tambahkan input search
const input = document.createElement("input");
input.type = "text";
input.placeholder = "Cari alamat...";
- input.style = "width: 100%; padding: 8px; margin-bottom: 10px;";
- mapEl.parentNode.insertBefore(input, mapEl);
-
+ input.id = "search-input";
+ input.style.cssText = `
+ position: absolute;
+ top: 10px;
+ left: 50%;
+ transform: translateX(-50%);
+ z-index: 5;
+ width: 300px;
+ padding: 6px;
+ font-size: 14px;
+ border-radius: 4px;
+ border: 1px solid #ccc;
+ background: white;
+ `;
+ mapEl.appendChild(input);
+
+ // Gunakan Autocomplete klasik (deprecated tapi stabil)
const autocomplete = new google.maps.places.Autocomplete(input);
autocomplete.addListener("place_changed", () => {
const place = autocomplete.getPlace();
- if (place.geometry) {
- const loc = place.geometry.location;
- map.setCenter(loc);
- marker.position = loc;
-
- this.trigger_up("field_changed", {
- dataPointID: this.dataPointID,
- changes: {
- latitude: loc.lat().toString(),
- longtitude: loc.lng().toString(),
- },
- viewType: this.viewType,
- });
+ if (place && place.geometry && place.geometry.location) {
+ const pos = place.geometry.location;
+ map.setCenter(pos);
+ marker.position = pos;
+ this._updateCoordinates(pos.lat(), pos.lng());
}
});
}
},
+ _updateCoordinates(lat, lng) {
+ this.trigger_up("field_changed", {
+ dataPointID: this.dataPointID,
+ changes: {
+ latitude: lat.toString(),
+ longtitude: lng.toString(),
+ },
+ viewType: this.viewType,
+ });
+ },
+
isSet() {
return true;
},
diff --git a/indoteknik_custom/models/res_partner.py b/indoteknik_custom/models/res_partner.py
index 6ef5698c..380761b4 100644
--- a/indoteknik_custom/models/res_partner.py
+++ b/indoteknik_custom/models/res_partner.py
@@ -149,7 +149,7 @@ class ResPartner(models.Model):
longtitude = fields.Char(string='Longtitude')
latitude = fields.Char(string='Latitude')
map_view = fields.Char(string='Map')
- address_map = fields.Char(string='Address Map')
+ address_map = fields.Char(string='Address Map', help='Ini adalah alamat yang didapatkan dari pin point pada peta')
company_type = fields.Selection(string='Company Type',
selection=[('person', 'Individual'), ('company', 'Company')],
compute='_compute_company_type', inverse='_write_company_type', tracking=3)