Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google route map control #472

Draft
wants to merge 19 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
1f8b816
:sparkles: Add routecontrol for google direction api.
volterra79 May 10, 2023
b746492
:sparkles: Customize icon and showIcon user message
volterra79 May 10, 2023
12fd562
:sparkles: Add travel mode bus bike.
volterra79 May 11, 2023
6d5f890
:sparkles:Create map control items for map control
volterra79 May 11, 2023
8c13a25
:sparkles:dd language to request
volterra79 May 11, 2023
fe9248d
:sparkles:Add details
volterra79 May 11, 2023
799cde4
:sparkles: Improve details e show line of route
volterra79 May 12, 2023
4ba9f77
Merge branch 'dev' into mapcontrol_google_route_direction_api
volterra79 May 17, 2023
b78e9dd
Merge branch 'dev' into mapcontrol_google_route_direction_api
volterra79 May 17, 2023
c2ef069
Merge branch 'dev' into v3.7_feature_mapcontrol_google_route_directio…
volterra79 Aug 8, 2023
e46a574
:bug: Fix bounds route attributes
volterra79 Aug 8, 2023
0b9fd1d
:bulb: Remove console
volterra79 Aug 8, 2023
1d53f74
Merge branch 'dev' into v3.7_feature_mapcontrol_google_route_directio…
volterra79 Aug 8, 2023
3613b51
:bug: Show only if google key is set
volterra79 Aug 8, 2023
64acf79
Merge branch 'dev' into v3.7_feature_mapcontrol_google_route_directio…
volterra79 Aug 8, 2023
6f89808
Merge branch 'dev' into v3.7_feature_mapcontrol_google_route_directio…
volterra79 Aug 16, 2023
19af1ad
Add closable right content when open route
volterra79 Aug 16, 2023
c492f7c
Merge branch 'dev' into v3.7_feature_mapcontrol_google_route_directio…
volterra79 Nov 16, 2023
4613528
Fix change dev merge
volterra79 Nov 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/app/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import G3W_CONSTANT from 'constant';

import ApplicationState from 'store/application-state';
import ApplicationService from 'services/application';
/**
* @since 3.9.0
*/
import ScriptsRegister from 'store/scripts';

/**
* Single File Components
Expand Down Expand Up @@ -265,17 +269,18 @@ module.exports = {

// G3W-SUITE debug info
info: () => {
$script(
'https://unpkg.com/[email protected]/platform.js',
() => {
ScriptsRegister.load({
url: 'https://unpkg.com/[email protected]/platform.js',
callback: () => {
window.console.info(`
[g3wsdk.info]\n
- g3w-admin: __${initConfig.version}__
- g3w-client: __${G3W_CONSTANT.APP_VERSION}__
- browser: __${platform.name} ${platform.version}__
- operating system: __${platform.os.toString()}__
`.trim());
});
}
})
},

// G3W-CLIENT version
Expand Down
19 changes: 18 additions & 1 deletion src/app/constant.js
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,12 @@ export const FONT_AWESOME_ICONS = {
crop: "fas fa-crop-alt",
exit: "fas fa-door-open",
slider: "fas fa-sliders-h",
car: "fas fa-car",
walking: "fas fa-walking",
/**
* @since 3.9.0
*/
route: "fas fa-route",

/**
* @since 3.8.0
Expand All @@ -577,7 +583,18 @@ export const FONT_AWESOME_ICONS = {
* @since 3.8.0
*/
share: "fas fa-share",

/**
* @since 3.9.0
*/
'circle-close': "far fa-times-circle",
/**
* @since 3.9.0
*/
'bicycle': "fas fa-bicycle",
/**
* @since 3.9.0
*/
'bus': "fas fa-bus",
};

/**
Expand Down
92 changes: 65 additions & 27 deletions src/app/g3w-ol/controls/interactioncontrol.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ const InteractionControl = function(options={}) {
toggledTool,
interactionClassOptions={},
layers=[],
spatialMethod
spatialMethod,
//since 3.8.1
controlItems,
} = options;

/**
Expand Down Expand Up @@ -79,6 +81,11 @@ const InteractionControl = function(options={}) {

this.toggledTool;

/**
* @since 3.9.0
*/
this.controlItemsElement;

this._interactionClassOptions = interactionClassOptions;

options.buttonClickHandler = InteractionControl.prototype._handleClick.bind(this);
Expand All @@ -100,6 +107,10 @@ const InteractionControl = function(options={}) {
this.createControlTool(toggledTool);
}

if (controlItems) {
this.createControlItems(controlItems);
}

// set enabled
this.setEnable(enabled);

Expand Down Expand Up @@ -225,6 +236,15 @@ proto.disable = function() {
$(this.element).addClass('g3w-disabled');
};

/**
* @since 3.9.0
*/

proto.createControlItems = function(controlItems={}){
const {component} = controlItems;
this.controlItemsElement = new Vue(component).$mount().$el;
}

/**
* @param {{ type: {'spatialMethod' | 'custom'}, component: unknown, how: {'toggled' | 'hover'} }} toggledTool
*/
Expand All @@ -235,39 +255,44 @@ proto.createControlTool = function(toggledTool={}) {
* 'hover' => (show button tool as info help)
* }
*/
const {type, component, how="toggled"} = toggledTool;
const {type, component, how="toggled", title, showIcon, iconClass, userMessageType} = toggledTool;
switch(type) {
case 'spatialMethod':
const method = this.getSpatialMethod();
this.toggledTool = {
data() {
this.methods = SPATIAL_METHODS;
return {
method
title,
component: {
data() {
this.methods = SPATIALMETHODS;
return {
method
}
},
template: `
<div style="width: 100%; padding: 5px;">
<select ref="select" style="width: 100%" :search="false" v-select2="'method'">
<option v-for="method in methods">{{method}}</option>
</select>
</div>`,
watch: {
'method': method => this.setSpatialMethod(method)
},
created() {
GUI.setCloseUserMessageBeforeSetContent(false);
},
beforeDestroy() {
GUI.setCloseUserMessageBeforeSetContent(true);
}
},
template: `
<div style="width: 100%; padding: 5px;">
<select ref="select" style="width: 100%" :search="false" v-select2="'method'">
<option v-for="method in methods">{{method}}</option>
</select>
</div>`,
watch: {
'method': method => this.setSpatialMethod(method)
},
created() {
GUI.setCloseUserMessageBeforeSetContent(false);
},
beforeDestroy() {
GUI.setCloseUserMessageBeforeSetContent(true);
}
};
}
break;
case 'custom':
this.toggledTool = component;
default:
this.toggledTool = {title, component, showIcon, iconClass, userMessageType};
break;
// if we want to create a button (as info on hover)
}

switch (how) {
case 'hover':
this._createToolOnHoverButton();
Expand All @@ -291,13 +316,15 @@ proto._createToolOnHoverButton = function() {
proto.showToggledTool = function(show=true) {
if (show) {
GUI.showUserMessage({
title: '',
type: 'tool',
title: this.toggledTool.title || '',
type: this.toggledTool.userMessageType ||'tool',
size: 'small',
iconClass: this.toggledTool.iconClass,
showIcon: this.toggledTool.showIcon,
closable: this._toolButton ? true : false,
hooks: {
body: this.toggledTool
}
body: this.toggledTool.component
},
});
} else GUI.closeUserMessage();
};
Expand Down Expand Up @@ -388,6 +415,17 @@ proto.toggle = function(toggled = !this._toggled) {
this.showToggledTool(this._toggled);
}

/**
* @since 3.9.0
*/
if (this.controlItemsElement) {
if (toggled) {
GUI.getService('map').showMapControlsItems(this.controlItemsElement);
} else {
GUI.getService('map').hideMapControlsItems();
}
}

this.dispatchEvent({ type: 'toggled', toggled });

};
Expand Down
Loading