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

clean up and add documentation #9

Open
wants to merge 2 commits into
base: support_refactoring
Choose a base branch
from

Conversation

MV88
Copy link

@MV88 MV88 commented Oct 13, 2020

Clean up and documentation

# Conflicts:
#	web/client/map/hooks/use-map-tool.js
@@ -14,15 +22,19 @@ const defaultOpt = {
maxZoom: 18
}
};

/**
* Common interface shared across multiple map types
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not an interface, this is a Component

Copy link
Author

@MV88 MV88 Oct 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah i know, i thought to add special category and not just call it component

going to fix it with "Locate Tool Component shared across multiple map types"

/**
* Common interface shared across multiple map types
* @prop {object} map the map object
* @prop {string} mapType can be openlayers, leaflet or cesium
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why should we limit this to the actual implementations? There is nothing that prevents having a MapBoxGL api here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no intention to to limit maptypes here, just they are the one currently implemented

going to remove the list

* @prop {object} map the map object
* @prop {string} mapType can be openlayers, leaflet or cesium
* @prop {string} status locate status: DISABLED, FOLLOWING, ENABLED, LOCATING, PERMISSION_DENIED
* @prop {string} message a message to show
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @prop {string} message a message to show
* @prop {string} messages message to be shown when location is found

* @prop {string} mapType can be openlayers, leaflet or cesium
* @prop {string} status locate status: DISABLED, FOLLOWING, ENABLED, LOCATING, PERMISSION_DENIED
* @prop {string} message a message to show
* @prop {function} changeLocateState callback to run when state changes
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @prop {function} changeLocateState callback to run when state changes
* @prop {function} changeLocateState callback to run when status changes

@@ -34,8 +46,13 @@ const LocateTool = ({map, mapType, status, messages, changeLocateState, onLocate
changeLocateState("DISABLED");
};

/**
* when loaded do something, use the start method
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this comment useful?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i was thinking it could be useful for new comers but i get your point of no-comment at all 😝

@@ -45,10 +62,23 @@ const LocateTool = ({map, mapType, status, messages, changeLocateState, onLocate
locateInstance.current?.clear();
};
}, [loaded]);

/**
* when some of the props changes run an update
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this comment needed?

useEffect(() => {
locateInstance.current?.update({status, messages});
}, [status, messages, loaded]);

/**
* when there is an error run the callbacks that handles it
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this comment needed?

@@ -8,7 +8,13 @@

import {useEffect, useRef, useState} from "react";

const useMapTool = (mapType, tool) => {
/**
* hook used to load in an asynchronous way a tool
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* hook used to load in an asynchronous way a tool
* Hook that can be used to load a tool in an asynchronous way

const useMapTool = (mapType, tool) => {
/**
* hook used to load in an asynchronous way a tool
* @param {string} mapType can be openlayers, leaflet or cesium
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I won't limit the possible values here

* hook used to load in an asynchronous way a tool
* @param {string} mapType can be openlayers, leaflet or cesium
* @param {string} tool the name of the tool, should match a file in web/client/map/<mapType> folder
* @return {[boolean, object, object]} loaded if the tool has been correctly loaded, impl.current is the reference to the tool, error is an object containing the possible error that can occur while loading
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @return {[boolean, object, object]} loaded if the tool has been correctly loaded, impl.current is the reference to the tool, error is an object containing the possible error that can occur while loading
* @return {[boolean, object, object]} [loaded, tool_implementation, error]: loaded is false until the tool has been correctly loaded, tool_implementation is a ReactJS reference to the tool, error is an object containing an error if the tool implementaion cannot be loaded

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants