toggle style

This commit is contained in:
j 2025-08-11 19:55:08 +02:00
commit 529277eb12

View file

@ -719,10 +719,6 @@ Ox.Map = function(options, self) {
- self.options.showZoombar * 16; - self.options.showZoombar * 16;
} }
function getMapType() {
return self.options.showLabels ? 'HYBRID' : 'SATELLITE'
}
function getMaxZoom(point, callback) { function getMaxZoom(point, callback) {
if (arguments.length == 1) { if (arguments.length == 1) {
callback = point; callback = point;
@ -945,11 +941,8 @@ Ox.Map = function(options, self) {
self.center = mapBounds ? mapBounds.getCenter() : new maplibregl.LngLat(0, 0); self.center = mapBounds ? mapBounds.getCenter() : new maplibregl.LngLat(0, 0);
self.zoom = self.minZoom; self.zoom = self.minZoom;
window.map = that.map = self.map = new maplibregl.Map({
container: self.$map[0], self.sateliteStyle = {
center: self.center,
style2: self.options.style,
style: {
'version': 8, 'version': 8,
'sources': { 'sources': {
'raster-tiles': { 'raster-tiles': {
@ -963,7 +956,7 @@ Ox.Map = function(options, self) {
'tileSize': 256, 'tileSize': 256,
'attribution': 'attribution':
'FIXME', 'FIXME',
} },
}, },
'layers': [ 'layers': [
{ {
@ -973,10 +966,13 @@ Ox.Map = function(options, self) {
'roundZoom': true, 'roundZoom': true,
'minzoom': 0, 'minzoom': 0,
'maxzoom': 22 'maxzoom': 22
} },
] ]
}, };
//mapTypeId: google.maps.MapTypeId[getMapType()], window.map = that.map = self.map = new maplibregl.Map({
container: self.$map[0],
center: self.center,
style: self.options.showLabels ? self.options.style : self.sateliteStyle,
//noClear: true, //noClear: true,
//scrollwheel: !self.options.zoomOnlyWhenFocused, //scrollwheel: !self.options.zoomOnlyWhenFocused,
zoom: self.zoom zoom: self.zoom
@ -1221,15 +1217,19 @@ Ox.Map = function(options, self) {
} }
function getType(types, data) { function getType(types, data) {
// see https://developers.google.com/maps/documentation/javascript/geocoding#GeocodingAddressTypes // see https://developers.google.com/maps/documentation/javascript/geocoding#GeocodingAddressTypes
types.push(data.properties.addresstype) types.unshift(data.properties.addresstype)
console.log(types)
var strings = { var strings = {
'country': ['country'], 'country': ['country'],
'region': [ 'region': [
'administrative_area', 'colloquial_area', 'administrative_area', 'colloquial_area',
'state', 'county' 'state', 'county', 'region'
],
'city': [
'locality', 'city', 'town'
], ],
'city': ['locality', 'city'],
'borough': ['neighborhood', 'postal_code', 'sublocality', 'suburb', 'borough'], 'borough': ['neighborhood', 'postal_code', 'sublocality', 'suburb', 'borough'],
'street': [ 'street': [
'intersection', 'route', 'intersection', 'route',
@ -1490,7 +1490,7 @@ Ox.Map = function(options, self) {
function toggleLabels() { function toggleLabels() {
self.options.showLabels = !self.options.showLabels; self.options.showLabels = !self.options.showLabels;
self.map.setMapTypeId(google.maps.MapTypeId[getMapType()]); self.map.setStyle(self.options.showLabels ? self.options.style : self.sateliteStyle)
that.triggerEvent('togglelabels', { that.triggerEvent('togglelabels', {
visible: self.options.showLabels visible: self.options.showLabels
}); });