mirror of
https://github.com/a2nt/webpack-bootstrap-ui-kit.git
synced 2024-10-22 11:05:45 +02:00
Fix single marker positioning
This commit is contained in:
parent
91462819df
commit
0873f18478
@ -4,7 +4,7 @@ import $ from 'jquery';
|
||||
import Events from '../../_events';
|
||||
import MarkerUI from './_map.google.marker';
|
||||
|
||||
const GoogleMapsDriver = (($) => {
|
||||
const GoogleMapsDriver = ($ => {
|
||||
class GoogleMapsDriver {
|
||||
getName() {
|
||||
return 'GoogleMapsDriver';
|
||||
@ -39,13 +39,13 @@ const GoogleMapsDriver = (($) => {
|
||||
const zoom = config['mapZoom'] ? config['mapZoom'] : 10;
|
||||
const center = config['center']
|
||||
? {
|
||||
lat: config['center'][1],
|
||||
lng: config['center'][0],
|
||||
}
|
||||
lat: config['center'][1],
|
||||
lng: config['center'][0],
|
||||
}
|
||||
: {
|
||||
lat: 0,
|
||||
lng: 0,
|
||||
};
|
||||
lat: 0,
|
||||
lng: 0,
|
||||
};
|
||||
const style = config['style'] ? config['style'] : null;
|
||||
|
||||
console.log(`${ui.getName()}: API is loaded`);
|
||||
@ -124,7 +124,7 @@ const GoogleMapsDriver = (($) => {
|
||||
|
||||
$popup.find('.mapboxgl-popup-content .html').html(content);
|
||||
|
||||
$popup.find('.mapboxgl-popup-close-button').on('click', (e) => {
|
||||
$popup.find('.mapboxgl-popup-close-button').on('click', e => {
|
||||
e.preventDefault();
|
||||
ui.hidePopup();
|
||||
});
|
||||
@ -209,7 +209,7 @@ const GoogleMapsDriver = (($) => {
|
||||
const bounds = new google.maps.LatLngBounds();
|
||||
|
||||
// add markers to map
|
||||
config['geojson'].features.forEach((marker) => {
|
||||
config['geojson'].features.forEach(marker => {
|
||||
const id = marker.id;
|
||||
const crds = marker.geometry.coordinates;
|
||||
const content = marker.properties.content;
|
||||
@ -227,9 +227,13 @@ const GoogleMapsDriver = (($) => {
|
||||
});
|
||||
});
|
||||
|
||||
ui.map.fitBounds(bounds, {
|
||||
padding: 30,
|
||||
}); //panToBounds
|
||||
if (ui.markers.length > 1) {
|
||||
ui.map.fitBounds(bounds, {
|
||||
padding: 30,
|
||||
}); //panToBounds
|
||||
} else {
|
||||
ui.map.setCenter(ui.markers[0].position);
|
||||
}
|
||||
|
||||
ui.default_bounds = bounds;
|
||||
ui.default_zoom = ui.map.getZoom();
|
||||
|
Loading…
Reference in New Issue
Block a user