Updated the Google Maps API endpoints for improved performance and compatibility
This commit is contained in:
@@ -237,15 +237,16 @@ class ContactControllerCore extends FrontController
|
||||
$this->addJS(_PS_JS_DIR_.'validate.js');
|
||||
|
||||
// GOOGLE MAP
|
||||
if (($PS_API_KEY = Configuration::get('PS_API_KEY')) && Configuration::get('WK_GOOGLE_ACTIVE_MAP')) {
|
||||
if (($PS_API_KEY = Configuration::get('PS_API_KEY')) && ($PS_MAP_ID = Configuration::get('PS_MAP_ID')) && Configuration::get('WK_GOOGLE_ACTIVE_MAP')) {
|
||||
Media::addJsDef(
|
||||
array(
|
||||
'PS_STORES_ICON' => $this->context->link->getMediaLink(_PS_IMG_.Configuration::get('PS_STORES_ICON')),
|
||||
'PS_MAP_ID' => $PS_MAP_ID,
|
||||
)
|
||||
);
|
||||
$this->addJS(
|
||||
'https://maps.googleapis.com/maps/api/js?key='.$PS_API_KEY.
|
||||
'&libraries=places&language='.$this->context->language->iso_code.'®ion='.$this->context->country->iso_code
|
||||
'&libraries=places,marker&loading=async&callback=initMap&language='.$this->context->language->iso_code.'®ion='.$this->context->country->iso_code
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -639,6 +639,7 @@ class GuestTrackingControllerCore extends FrontController
|
||||
if (Validate::isLoadedObject($objHotelBranchInformation)) {
|
||||
if (($apiKey = Configuration::get('PS_API_KEY'))
|
||||
&& Configuration::get('WK_GOOGLE_ACTIVE_MAP')
|
||||
&& ($PS_MAP_ID = Configuration::get('PS_MAP_ID'))
|
||||
) {
|
||||
if (floatval($objHotelBranchInformation->latitude) != 0
|
||||
&& floatval($objHotelBranchInformation->longitude) != 0
|
||||
@@ -646,10 +647,11 @@ class GuestTrackingControllerCore extends FrontController
|
||||
Media::addJsDef(array(
|
||||
'PS_STORES_ICON' => $this->context->link->getMediaLink(_PS_IMG_.Configuration::get('PS_STORES_ICON')),
|
||||
'initiateMap' => 1,
|
||||
'PS_MAP_ID' => $PS_MAP_ID,
|
||||
));
|
||||
|
||||
$this->addJS(
|
||||
'https://maps.googleapis.com/maps/api/js?key='.$apiKey.'&libraries=places&language='.
|
||||
'https://maps.googleapis.com/maps/api/js?key='.$apiKey.'&libraries=places,marker&loading=async&callback=initMap&language='.
|
||||
$this->context->language->iso_code.'®ion='.$this->context->country->iso_code
|
||||
);
|
||||
|
||||
|
||||
@@ -871,6 +871,7 @@ class OrderDetailControllerCore extends FrontController
|
||||
if (Validate::isLoadedObject($objHotelBranchInformation)) {
|
||||
if (($apiKey = Configuration::get('PS_API_KEY'))
|
||||
&& Configuration::get('WK_GOOGLE_ACTIVE_MAP')
|
||||
&& ($PS_MAP_ID = Configuration::get('PS_MAP_ID'))
|
||||
) {
|
||||
if (floatval($objHotelBranchInformation->latitude) != 0
|
||||
&& floatval($objHotelBranchInformation->longitude) != 0
|
||||
@@ -878,10 +879,10 @@ class OrderDetailControllerCore extends FrontController
|
||||
Media::addJsDef(array(
|
||||
'PS_STORES_ICON' => $this->context->link->getMediaLink(_PS_IMG_.Configuration::get('PS_STORES_ICON')),
|
||||
'initiateMap' => 1,
|
||||
'PS_MAP_ID' => $PS_MAP_ID,
|
||||
));
|
||||
|
||||
$this->addJS(
|
||||
'https://maps.googleapis.com/maps/api/js?key='.$apiKey.'&libraries=places&language='.
|
||||
'https://maps.googleapis.com/maps/api/js?key='.$apiKey.'&libraries=places,marker&loading=async&callback=initMap&language='.
|
||||
$this->context->language->iso_code.'®ion='.$this->context->country->iso_code
|
||||
);
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ class OurPropertiesControllerCore extends FrontController
|
||||
$hotelsInfo = array_slice($hotelsInfo, $page * 10, 10);
|
||||
}
|
||||
|
||||
if ($displayHotelMap && Configuration::get('PS_API_KEY') && Configuration::get('WK_GOOGLE_ACTIVE_MAP')) {
|
||||
if ($displayHotelMap && Configuration::get('PS_API_KEY') && Configuration::get('WK_GOOGLE_ACTIVE_MAP') && Configuration::get('PS_MAP_ID')) {
|
||||
if ($hotelLocations = $objHotelInfo->getMapFormatHotelsInfo(Configuration::get('WK_MAP_HOTEL_ACTIVE_ONLY'))) {
|
||||
$hotelLocationArray = str_replace(array('\n', '\r'), '', json_encode($hotelLocations));
|
||||
}
|
||||
@@ -144,16 +144,17 @@ class OurPropertiesControllerCore extends FrontController
|
||||
$this->addJS(_THEME_JS_DIR_.'our-properties.js');
|
||||
$this->addCSS(_THEME_CSS_DIR_.'our-properties.css');
|
||||
// GOOGLE MAP
|
||||
if (($PS_API_KEY = Configuration::get('PS_API_KEY')) && Configuration::get('WK_GOOGLE_ACTIVE_MAP')) {
|
||||
if (($PS_API_KEY = Configuration::get('PS_API_KEY')) && ($PS_MAP_ID = Configuration::get('PS_MAP_ID')) && Configuration::get('WK_GOOGLE_ACTIVE_MAP')) {
|
||||
Media::addJsDef(
|
||||
array(
|
||||
'PS_STORES_ICON' => $this->context->link->getMediaLink(_PS_IMG_.Configuration::get('PS_STORES_ICON')),
|
||||
'PS_MAP_ID' => $PS_MAP_ID
|
||||
)
|
||||
);
|
||||
|
||||
$this->addJS(
|
||||
'https://maps.googleapis.com/maps/api/js?key='.$PS_API_KEY.
|
||||
'&libraries=places&language='.$this->context->language->iso_code.'®ion='.$this->context->country->iso_code
|
||||
'&libraries=places,marker&loading=async&callback=initMap&language='.$this->context->language->iso_code.'®ion='.$this->context->country->iso_code
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,10 +66,11 @@ class ProductControllerCore extends FrontController
|
||||
$this->addJqueryPlugin('jqzoom');
|
||||
}
|
||||
|
||||
if (($PS_API_KEY = Configuration::get('PS_API_KEY'))) {
|
||||
if (($PS_API_KEY = Configuration::get('PS_API_KEY'))
|
||||
&& ($PS_MAP_ID = Configuration::get('PS_MAP_ID'))
|
||||
) {
|
||||
$objHotelRoomType = new HotelRoomType();
|
||||
$roomTypeInfo = $objHotelRoomType->getRoomTypeInfoByIdProduct($this->product->id);
|
||||
if ($roomTypeInfo) {
|
||||
if ($roomTypeInfo = $objHotelRoomType->getRoomTypeInfoByIdProduct($this->product->id)) {
|
||||
$objHotelBranchInformation = new HotelBranchInformation($roomTypeInfo['id_hotel']);
|
||||
if (floatval($objHotelBranchInformation->latitude) != 0
|
||||
&& floatval($objHotelBranchInformation->longitude) != 0
|
||||
@@ -79,12 +80,13 @@ class ProductControllerCore extends FrontController
|
||||
'latitude' => $objHotelBranchInformation->latitude,
|
||||
'longitude' => $objHotelBranchInformation->longitude,
|
||||
),
|
||||
'PS_STORES_ICON' => $this->context->link->getMediaLink(_PS_IMG_.Configuration::get('PS_STORES_ICON'))
|
||||
'PS_STORES_ICON' => $this->context->link->getMediaLink(_PS_IMG_.Configuration::get('PS_STORES_ICON')),
|
||||
'PS_MAP_ID' => $PS_MAP_ID
|
||||
));
|
||||
|
||||
$this->addJS(
|
||||
'https://maps.googleapis.com/maps/api/js?key='.$PS_API_KEY.'&libraries=places&language='.
|
||||
$this->context->language->iso_code.'®ion='.$this->context->country->iso_code
|
||||
'https://maps.googleapis.com/maps/api/js?key='.$PS_API_KEY.
|
||||
'&libraries=places,marker&loading=async&callback=initMap&language='.$this->context->language->iso_code.'®ion='.$this->context->country->iso_code
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ class AdminAddHotelController extends ModuleAdminController
|
||||
}
|
||||
|
||||
$smartyVars['state_var'] = $stateOptions;
|
||||
$smartyVars['enabledDisplayMap'] = Configuration::get('PS_API_KEY') && Configuration::get('WK_GOOGLE_ACTIVE_MAP');
|
||||
$smartyVars['enabledDisplayMap'] = Configuration::get('PS_API_KEY') && Configuration::get('PS_MAP_ID') && Configuration::get('WK_GOOGLE_ACTIVE_MAP');
|
||||
$smartyVars['ps_img_dir'] = _PS_IMG_.'l/';
|
||||
$smartyVars['PS_MAX_CHECKOUT_OFFSET'] = (int) Configuration::get('PS_MAX_CHECKOUT_OFFSET');
|
||||
$smartyVars['PS_MIN_BOOKING_OFFSET'] = (int) Configuration::get('PS_MIN_BOOKING_OFFSET');
|
||||
@@ -605,8 +605,8 @@ class AdminAddHotelController extends ModuleAdminController
|
||||
$objHotelBranch->check_in = $check_in;
|
||||
$objHotelBranch->check_out = $check_out;
|
||||
$objHotelBranch->rating = $rating;
|
||||
$objHotelBranch->latitude = $latitude;
|
||||
$objHotelBranch->longitude = $longitude;
|
||||
$objHotelBranch->latitude = Tools::ps_round($latitude, 8);
|
||||
$objHotelBranch->longitude = Tools::ps_round($longitude, 8);
|
||||
$objHotelBranch->map_formated_address = $map_formated_address;
|
||||
$objHotelBranch->map_input_text = $map_input_text;
|
||||
$objHotelBranch->save();
|
||||
@@ -984,15 +984,16 @@ class AdminAddHotelController extends ModuleAdminController
|
||||
'primaryHotelId' => Configuration::get('WK_PRIMARY_HOTEL'),
|
||||
'disableHotelMsg' => $this->l('Primary hotel for website will be updated to first available active hotel.', null, true),
|
||||
'PS_STORES_ICON' => $this->context->link->getMediaLink(_PS_IMG_.Configuration::get('PS_STORES_ICON')),
|
||||
'PS_MAP_ID' => ($PS_MAP_ID = Configuration::get('PS_MAP_ID'))
|
||||
)
|
||||
);
|
||||
// GOOGLE MAP
|
||||
$language = $this->context->language;
|
||||
$country = $this->context->country;
|
||||
if ($PS_API_KEY = Configuration::get('PS_API_KEY')) {
|
||||
if (($PS_API_KEY = Configuration::get('PS_API_KEY')) && $PS_MAP_ID) {
|
||||
$this->addJS(
|
||||
'https://maps.googleapis.com/maps/api/js?key='.$PS_API_KEY.'&libraries=places&language='.
|
||||
$language->iso_code.'®ion='.$country->iso_code
|
||||
'https://maps.googleapis.com/maps/api/js?key='.$PS_API_KEY.'&libraries=places,marker&loading=async&language='.
|
||||
$language->iso_code.'®ion='.$country->iso_code.'&callback=initGoogleMaps'
|
||||
);
|
||||
}
|
||||
//tinymce
|
||||
|
||||
@@ -397,6 +397,11 @@ class AdminHotelGeneralSettingsController extends ModuleAdminController
|
||||
'hint' => $this->l('Unique API key for Google Maps.'),
|
||||
'type' => 'text',
|
||||
),
|
||||
'PS_MAP_ID' => array(
|
||||
'title' => $this->l('Google Maps Id'),
|
||||
'hint' => $this->l('Map Id for Google Maps.'),
|
||||
'type' => 'text'
|
||||
),
|
||||
'WK_GOOGLE_ACTIVE_MAP' => array(
|
||||
'title' => $this->l('Display Google Maps For Hotel Location'),
|
||||
'cast' => 'intval',
|
||||
|
||||
@@ -285,6 +285,7 @@ class HotelReservationSystem extends Module
|
||||
if (Tools::getValue('controller') == 'category') {
|
||||
if (($apiKey = Configuration::get('PS_API_KEY'))
|
||||
&& Configuration::get('WK_GOOGLE_ACTIVE_MAP')
|
||||
&& ($PS_MAP_ID = Configuration::get('PS_MAP_ID'))
|
||||
) {
|
||||
$idCategory = Tools::getValue('id_category');
|
||||
$idHotel = HotelBranchInformation::getHotelIdByIdCategory($idCategory);
|
||||
@@ -299,13 +300,14 @@ class HotelReservationSystem extends Module
|
||||
'longitude' => $objHotel->longitude,
|
||||
'map_input_text' => $objHotel->map_input_text,
|
||||
),
|
||||
'PS_MAP_ID' => $PS_MAP_ID,
|
||||
'hotel_name' => $objHotel->hotel_name,
|
||||
'PS_STORES_ICON' => $this->context->link->getMediaLink(_PS_IMG_.Configuration::get('PS_STORES_ICON')),
|
||||
));
|
||||
|
||||
$this->context->controller->addJS(
|
||||
'https://maps.googleapis.com/maps/api/js?key='.$apiKey.'&libraries=places&language='.
|
||||
$this->context->language->iso_code.'®ion='.$this->context->country->iso_code
|
||||
'https://maps.googleapis.com/maps/api/js?key='.$apiKey.
|
||||
'&libraries=places,marker&loading=async&callback=initMap&language='.$this->context->language->iso_code.'®ion='.$this->context->country->iso_code
|
||||
);
|
||||
$this->context->controller->addJS($this->getPathUri().'views/js/searchResultsMap.js');
|
||||
$this->context->controller->addCSS($this->getPathUri().'views/css/searchResultsMap.css');
|
||||
|
||||
@@ -472,10 +472,7 @@ p.room_cat_data
|
||||
}
|
||||
|
||||
#pac-input {
|
||||
background-color: #fff;
|
||||
height: 38px;
|
||||
width: 300px;
|
||||
font-size: 14px;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,17 +22,12 @@ var GoogleMapsManager = {
|
||||
defaultZoom: 10,
|
||||
map: null,
|
||||
markers: [],
|
||||
placesService: null,
|
||||
placeService: null,
|
||||
|
||||
init: function(jQDiv) {
|
||||
this.mapDiv = jQDiv;
|
||||
this.geocoder = new google.maps.Geocoder();
|
||||
},
|
||||
setPlacesService: function() {
|
||||
if (!this.placesService && this.map) {
|
||||
this.placesService = new google.maps.places.PlacesService(this.map);
|
||||
}
|
||||
},
|
||||
setDefaultLatLng: function(cb) {
|
||||
if (!this.defaultLatLng) {
|
||||
var latitude = Number($("#loclatitude").val());
|
||||
@@ -64,6 +59,24 @@ var GoogleMapsManager = {
|
||||
}
|
||||
}
|
||||
},
|
||||
fetchFields: async function(request) {
|
||||
if (!request.placeId) return;
|
||||
const place = new google.maps.places.Place({
|
||||
id: request.placeId
|
||||
});
|
||||
|
||||
const fieldsRequest = {
|
||||
fields: ["displayName", "formattedAddress", "location"]
|
||||
};
|
||||
|
||||
try {
|
||||
await place.fetchFields(fieldsRequest);
|
||||
this.placeService = place;
|
||||
return place;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
},
|
||||
initMap: function(cb) {
|
||||
if (!this.map) {
|
||||
var that = this;
|
||||
@@ -71,85 +84,26 @@ var GoogleMapsManager = {
|
||||
that.map = new google.maps.Map($(that.mapDiv).get(0), {
|
||||
zoom: that.defaultZoom,
|
||||
clickableIcons: true,
|
||||
mapId: PS_MAP_ID
|
||||
});
|
||||
that.map.setCenter(that.defaultLatLng);
|
||||
if (that.defaultLatLng && that.formattedAddress) {
|
||||
that.addMarker(that.defaultLatLng, null, that.formattedAddress);
|
||||
}
|
||||
that.setPlacesService();
|
||||
|
||||
// register marker events
|
||||
that.map.addListener('click', function (e) {
|
||||
var latLng = e.latLng;
|
||||
|
||||
var isInfoWindowNeeded = true;
|
||||
// if it is a Place Of Interest (POI), event contains the property 'placeId'
|
||||
if (Object.hasOwn(e, 'placeId')) {
|
||||
isInfoWindowNeeded = false;
|
||||
|
||||
that.geocoder.geocode({ location: latLng }, function (results, status) {
|
||||
if (status == google.maps.GeocoderStatus.OK && results[0]) {
|
||||
var request = {
|
||||
placeId: e.placeId,
|
||||
fields: ['name'],
|
||||
};
|
||||
|
||||
that.placesService.getDetails(request, function(place, status) {
|
||||
if (status === google.maps.places.PlacesServiceStatus.OK) {
|
||||
var content = '<div><h6>' + place.name + '</h6><p>' +
|
||||
results[0].formatted_address + '</p></div>';
|
||||
|
||||
var callback = function (latLng) {
|
||||
that.setFormVars({
|
||||
lat: latLng.lat(),
|
||||
lng: latLng.lng(),
|
||||
formattedAddress: content,
|
||||
inputText: $('#pac-input').val(),
|
||||
});
|
||||
}
|
||||
|
||||
that.addMarker(
|
||||
latLng,
|
||||
results[0],
|
||||
null,
|
||||
isInfoWindowNeeded,
|
||||
callback(latLng)
|
||||
);
|
||||
}
|
||||
});
|
||||
that.fetchFields({ placeId: e.placeId }).then(place => {
|
||||
if (place && place.location) {
|
||||
that.addMarker(place.location, null, place.formattedAddress);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
that.geocoder.geocode({ location: latLng }, function (results, status) {
|
||||
if (status == google.maps.GeocoderStatus.OK && results[0]) {
|
||||
var request = {
|
||||
placeId: results[0].place_id,
|
||||
fields: ['name'],
|
||||
};
|
||||
|
||||
that.placesService.getDetails(request, function(place, status) {
|
||||
if (status === google.maps.places.PlacesServiceStatus.OK) {
|
||||
var content = '<div><h6>' + place.name + '</h6><p>' +
|
||||
results[0].formatted_address + '</p></div>';
|
||||
|
||||
var callback = function (latLng) {
|
||||
that.setFormVars({
|
||||
lat: latLng.lat(),
|
||||
lng: latLng.lng(),
|
||||
formattedAddress: content,
|
||||
inputText: $('#pac-input').val(),
|
||||
});
|
||||
}
|
||||
|
||||
that.addMarker(
|
||||
latLng,
|
||||
results[0],
|
||||
null,
|
||||
isInfoWindowNeeded,
|
||||
callback(latLng)
|
||||
);
|
||||
}
|
||||
});
|
||||
that.geocoder.geocode({ location: latLng }, function(results, status) {
|
||||
if (status === 'OK' && results[0]) {
|
||||
that.addMarker(latLng, null, results[0].formatted_address);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -163,42 +117,37 @@ var GoogleMapsManager = {
|
||||
cb();
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
initAutocomplete: function(jQInput, cb) {
|
||||
var that = this;
|
||||
that.initMap(function() {
|
||||
that.autocompleteInput = jQInput;
|
||||
var input = $(that.autocompleteInput).get(0);
|
||||
that.map.controls[google.maps.ControlPosition.TOP_CENTER].push(input);
|
||||
that.autocomplete = new google.maps.places.Autocomplete(input);
|
||||
that.autocomplete.bindTo('bounds', that.map);
|
||||
|
||||
that.autocomplete.addListener('place_changed', function() {
|
||||
that.clearAllMarkers();
|
||||
var place = that.autocomplete.getPlace();
|
||||
|
||||
if (place.geometry.viewport) {
|
||||
that.map.fitBounds(place.geometry.viewport);
|
||||
} else {
|
||||
that.map.setCenter(place.geometry.location);
|
||||
that.map.setZoom(18);
|
||||
}
|
||||
var latLng = {
|
||||
lat: place.geometry.location.lat(),
|
||||
lng: place.geometry.location.lng(),
|
||||
};
|
||||
that.addMarker(latLng, place);
|
||||
|
||||
var content = '<div><h6>' + place.name + '</h6><p>' + place.formatted_address + '</p></div>';
|
||||
that.setFormVars({
|
||||
lat: latLng.lat,
|
||||
lng: latLng.lng,
|
||||
formattedAddress: content,
|
||||
inputText: $('#pac-input').val(),
|
||||
});
|
||||
that.autocomplete = new google.maps.places.PlaceAutocompleteElement({
|
||||
locationRestriction: that.map.getBounds()
|
||||
});
|
||||
|
||||
that.autocomplete.id = "place-autocomplete-input";
|
||||
input.appendChild(that.autocomplete);
|
||||
|
||||
that.map.controls[google.maps.ControlPosition.TOP_LEFT].push(input);
|
||||
that.infoWindow = new google.maps.InfoWindow({});
|
||||
that.autocomplete.addEventListener("gmp-select", async (event) => {
|
||||
const place = event.placePrediction.toPlace();
|
||||
|
||||
await place.fetchFields({
|
||||
fields: ["displayName", "formattedAddress", "location", "viewport"]
|
||||
});
|
||||
// Fit the map to the place
|
||||
if (place.viewport) {
|
||||
that.map.fitBounds(place.viewport);
|
||||
} else {
|
||||
that.map.setCenter(place.location);
|
||||
that.map.setZoom(18);
|
||||
}
|
||||
|
||||
that.addMarker(place.location, null, place.formattedAddress);
|
||||
});
|
||||
google.maps.event.addDomListener(input, 'keydown', function (e) {
|
||||
if (e.keyCode === 13) {
|
||||
e.preventDefault();
|
||||
@@ -213,11 +162,17 @@ var GoogleMapsManager = {
|
||||
addMarker: function(latLng, address = null, fa = null, addInfoWindow = true, cb = null) {
|
||||
var that = this;
|
||||
that.clearAllMarkers();
|
||||
var marker = new google.maps.Marker({
|
||||
|
||||
let icon = document.createElement('img');
|
||||
icon.src = PS_STORES_ICON;
|
||||
icon.style.width = '24px';
|
||||
icon.style.height = '24px';
|
||||
|
||||
var marker = new google.maps.marker.AdvancedMarkerElement({
|
||||
position: latLng,
|
||||
map: that.map,
|
||||
content: icon,
|
||||
draggable: true,
|
||||
icon: PS_STORES_ICON
|
||||
});
|
||||
that.markers.push(marker);
|
||||
marker.addListener('dragend', function(e) {
|
||||
@@ -237,22 +192,11 @@ var GoogleMapsManager = {
|
||||
// open info window
|
||||
that.addInfoWindow(marker, fa);
|
||||
} else {
|
||||
var request = {
|
||||
placeId: address.place_id,
|
||||
fields: ['name'],
|
||||
};
|
||||
|
||||
that.placesService.getDetails(request, function(place, status) {
|
||||
if (status === google.maps.places.PlacesServiceStatus.OK) {
|
||||
// open info window
|
||||
var content = '<div><h6>' + place.name + '</h6><p>' + address.formatted_address + '</p></div>';
|
||||
that.addInfoWindow(marker, content);
|
||||
|
||||
if(cb && typeof cb === 'function') {
|
||||
cb();
|
||||
}
|
||||
}
|
||||
});
|
||||
var content = '<div><h6>' + this.placeService.displayName + '</h6><p>' + address.formatted_address + '</p></div>';
|
||||
that.addInfoWindow(marker, content);
|
||||
if(cb && typeof cb === 'function') {
|
||||
cb();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(cb && typeof cb === 'function') {
|
||||
@@ -287,10 +231,10 @@ var GoogleMapsManager = {
|
||||
that.clearAllMarkers();
|
||||
});
|
||||
|
||||
var latLng = marker.getPosition();
|
||||
var latLng = marker.position;
|
||||
that.setFormVars({
|
||||
lat: latLng.lat(),
|
||||
lng: latLng.lng(),
|
||||
lat: latLng.lat,
|
||||
lng: latLng.lng,
|
||||
formattedAddress: content,
|
||||
inputText: $('#pac-input').val(),
|
||||
});
|
||||
@@ -988,8 +932,6 @@ $(document).ready(function() {
|
||||
$('input[name="min_booking_offset"]').closest('.form-group').show(200);
|
||||
}
|
||||
});
|
||||
|
||||
initGoogleMaps();
|
||||
});
|
||||
|
||||
function toggleGoogleMapsFields()
|
||||
|
||||
@@ -28,33 +28,36 @@ function initMap() {
|
||||
center: hotelLocation,
|
||||
disableDefaultUI: true,
|
||||
fullscreenControl: true,
|
||||
mapId: PS_MAP_ID
|
||||
});
|
||||
|
||||
const marker = new google.maps.Marker({
|
||||
position: hotelLocation,
|
||||
let icon = document.createElement('img');
|
||||
icon.src = PS_STORES_ICON;
|
||||
icon.style.width = '24px';
|
||||
icon.style.height = '24px';
|
||||
|
||||
const marker = new google.maps.marker.AdvancedMarkerElement({
|
||||
map: map,
|
||||
title: hotel_name,
|
||||
icon: PS_STORES_ICON
|
||||
position: hotelLocation,
|
||||
title: location.hotel_name,
|
||||
content: icon,
|
||||
});
|
||||
|
||||
marker.query = location.query || null;
|
||||
marker.latitude = hotelLocation.lat;
|
||||
marker.longitude = hotelLocation.lng;
|
||||
|
||||
marker.addListener('click', function() {
|
||||
let query = '';
|
||||
if (hotel_location.map_input_text != '') {
|
||||
query = hotel_location.map_input_text;
|
||||
} else {
|
||||
query = hotel_location.latitude + ',' + hotel_location.longitude;
|
||||
if (this.query) {
|
||||
query = this.query;
|
||||
} else if (this.latitude && this.longitude) {
|
||||
query = `${this.latitude},${this.longitude}`;
|
||||
}
|
||||
|
||||
window.open('https://www.google.com/maps/search/?api=1&query='+encodeURIComponent(query), '_blank');
|
||||
if (query) {
|
||||
window.open(`https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(query)}`, '_blank');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
if (typeof hotel_location == 'object'
|
||||
&& $('#search-results-wrap .map-wrap').length
|
||||
&& typeof google == 'object'
|
||||
&& typeof google.maps == 'object'
|
||||
) {
|
||||
initMap();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -303,7 +303,7 @@
|
||||
<input type="hidden" id="loclongitude" name="loclongitude" value="{if isset($edit)}{$hotel_info.longitude|escape:'htmlall':'UTF-8'}{/if}" />
|
||||
<input type="hidden" id="locformatedAddr" name="locformatedAddr" value="{if isset($edit)}{$hotel_info.map_formated_address}{/if}" />
|
||||
<input type="hidden" id="googleInputField" name="googleInputField" value="{if isset($edit)}{$hotel_info.map_input_text}{/if}" />
|
||||
<input id="pac-input" class="controls" type="text" placeholder="{l s='Search' mod='hotelreservationsystem'}">
|
||||
<div id="pac-input" class="controls" type="text"></div>
|
||||
<div id="map"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -48,15 +48,6 @@ $(document).ready(function() {
|
||||
});
|
||||
|
||||
showProductSelect($('select[name=id_order]').attr('value'));
|
||||
|
||||
//By Webkul JS for Map locations of the hotels on google Map
|
||||
if (typeof hotelLocationArray != 'undefined'
|
||||
&& $('#map').length
|
||||
&& typeof google == 'object'
|
||||
&& typeof google.maps == 'object'
|
||||
) {
|
||||
initMap();
|
||||
}
|
||||
});
|
||||
|
||||
function showProductSelect(id_order) {
|
||||
@@ -75,7 +66,7 @@ function initMap() {
|
||||
hotelLocationArray = JSON.parse(hotelLocationArray);
|
||||
|
||||
// Display a map on the page
|
||||
map = new google.maps.Map(document.getElementById("map"));
|
||||
map = new google.maps.Map(document.getElementById("map"), {mapId: PS_MAP_ID});
|
||||
google.maps.event.trigger(map, 'resize');
|
||||
|
||||
map.setTilt(45);
|
||||
@@ -88,14 +79,17 @@ function initMap() {
|
||||
$.each(hotelLocationArray, function(i, location) {
|
||||
var position = new google.maps.LatLng(location.latitude, location.longitude);
|
||||
bounds.extend(position);
|
||||
marker = new google.maps.Marker({
|
||||
position: position,
|
||||
map: map,
|
||||
title: location.hotel_name,
|
||||
animation: google.maps.Animation.DROP,
|
||||
icon: PS_STORES_ICON
|
||||
});
|
||||
let icon = document.createElement('img');
|
||||
icon.src = PS_STORES_ICON;
|
||||
icon.style.width = '24px';
|
||||
icon.style.height = '24px';
|
||||
|
||||
marker = new google.maps.marker.AdvancedMarkerElement({
|
||||
map: map,
|
||||
position: position,
|
||||
title: location.hotel_name,
|
||||
content: icon,
|
||||
});
|
||||
// Allow each marker to have an info window
|
||||
google.maps.event.addListener(marker, 'click', (function(marker, i) {
|
||||
return function() {
|
||||
|
||||
@@ -144,24 +144,36 @@ function initMap() {
|
||||
center: hotelLocation,
|
||||
disableDefaultUI: true,
|
||||
fullscreenControl: true,
|
||||
mapId: PS_MAP_ID
|
||||
});
|
||||
|
||||
const marker = new google.maps.Marker({
|
||||
let icon = document.createElement('img');
|
||||
icon.src = PS_STORES_ICON;
|
||||
icon.style.width = '24px';
|
||||
icon.style.height = '24px';
|
||||
|
||||
const marker = new google.maps.marker.AdvancedMarkerElement({
|
||||
position: hotelLocation,
|
||||
map: map,
|
||||
title: $(this).attr('title'),
|
||||
icon: PS_STORES_ICON
|
||||
title: location.hotel_name,
|
||||
content: icon,
|
||||
});
|
||||
|
||||
marker.query = location.query || null;
|
||||
marker.latitude = hotelLocation.lat;
|
||||
marker.longitude = hotelLocation.lng;
|
||||
|
||||
marker.addListener('click', function() {
|
||||
let query = '';
|
||||
if ($(this).attr('query') != '') {
|
||||
query = $(this).attr('query');
|
||||
} else {
|
||||
query = $(this).attr('latitude') + ',' + $(this).attr('longitude');
|
||||
if (this.query) {
|
||||
query = this.query;
|
||||
} else if (this.latitude && this.longitude) {
|
||||
query = `${this.latitude},${this.longitude}`;
|
||||
}
|
||||
|
||||
window.open('https://www.google.com/maps/search/?api=1&query='+encodeURIComponent(query), '_blank');
|
||||
if (query) {
|
||||
window.open(`https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(query)}`, '_blank');
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -376,14 +388,5 @@ $(document).ready(function () {
|
||||
});
|
||||
|
||||
initPriceTooltip();
|
||||
|
||||
if (typeof google === 'object'
|
||||
&& typeof google.maps === 'object'
|
||||
&& typeof initiateMap !== 'undefined'
|
||||
&& initiateMap === 1
|
||||
) {
|
||||
initMap();
|
||||
}
|
||||
|
||||
initRefundDeniedTooltip();
|
||||
});
|
||||
|
||||
@@ -21,15 +21,6 @@
|
||||
*/
|
||||
|
||||
$(document).ready(function() {
|
||||
//By Webkul JS for Map locations of the hotels on google Map
|
||||
if (typeof hotelLocationArray != 'undefined'
|
||||
&& $('#map').length
|
||||
&& typeof google == 'object'
|
||||
&& typeof google.maps == 'object'
|
||||
) {
|
||||
initMap();
|
||||
}
|
||||
|
||||
$(document).on('click', 'ul.pagination li a', function(e){
|
||||
e.preventDefault();
|
||||
$('#pagination').val($(this).data('pagination'));
|
||||
@@ -43,7 +34,7 @@ function initMap() {
|
||||
hotelLocationArray = JSON.parse(hotelLocationArray);
|
||||
|
||||
// Display a map on the page
|
||||
map = new google.maps.Map(document.getElementById("map"));
|
||||
map = new google.maps.Map(document.getElementById("map"), {mapId: PS_MAP_ID});
|
||||
google.maps.event.trigger(map, 'resize');
|
||||
|
||||
map.setTilt(45);
|
||||
@@ -56,12 +47,16 @@ function initMap() {
|
||||
$.each(hotelLocationArray, function(i, location) {
|
||||
var position = new google.maps.LatLng(location.latitude, location.longitude);
|
||||
bounds.extend(position);
|
||||
marker = new google.maps.Marker({
|
||||
position: position,
|
||||
let icon = document.createElement('img');
|
||||
icon.src = PS_STORES_ICON;
|
||||
icon.style.width = '24px';
|
||||
icon.style.height = '24px';
|
||||
|
||||
marker = new google.maps.marker.AdvancedMarkerElement({
|
||||
map: map,
|
||||
position: position,
|
||||
title: location.hotel_name,
|
||||
animation: google.maps.Animation.DROP,
|
||||
icon: PS_STORES_ICON
|
||||
content: icon,
|
||||
});
|
||||
|
||||
// Allow each marker to have an info window
|
||||
|
||||
@@ -1089,15 +1089,6 @@ $(document).ready(function() {
|
||||
}
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
if (typeof hotel_location == 'object'
|
||||
&& $('#room_type_map_tab .map-wrap').length
|
||||
&& typeof google == 'object'
|
||||
&& typeof google.maps == 'object'
|
||||
) {
|
||||
initMap();
|
||||
}
|
||||
|
||||
// normal product
|
||||
$(document).on('click', '.add_roomtype_product', function(e){
|
||||
e.preventDefault();
|
||||
@@ -1306,6 +1297,7 @@ function initMap() {
|
||||
const map = new google.maps.Map($('#room_type_map_tab .map-wrap').get(0), {
|
||||
zoom: 10,
|
||||
streetViewControl: false,
|
||||
mapId: PS_MAP_ID
|
||||
});
|
||||
|
||||
const hotelLatLng = {
|
||||
@@ -1314,11 +1306,14 @@ function initMap() {
|
||||
};
|
||||
|
||||
map.setCenter(hotelLatLng);
|
||||
|
||||
const marker = new google.maps.Marker({
|
||||
let icon = document.createElement('img');
|
||||
icon.src = PS_STORES_ICON;
|
||||
icon.style.width = '24px';
|
||||
icon.style.height = '24px';
|
||||
let marker = new google.maps.marker.AdvancedMarkerElement({
|
||||
position: hotelLatLng,
|
||||
map: map,
|
||||
icon: PS_STORES_ICON
|
||||
content: icon,
|
||||
});
|
||||
|
||||
const uiContent = $('#room-info-map-ui-content .hotel-info-wrap').get(0);
|
||||
|
||||
Reference in New Issue
Block a user