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

Changes for IITC #1

Closed
wants to merge 16 commits into from
Closed

Changes for IITC #1

wants to merge 16 commits into from

Conversation

modos189
Copy link

On one hand, this change is specific to IITC, and on other hand - for greater similarity with the leaflet. Perhaps we should create a parameter to determine whether the container should be destroyed.
See: b6c228a

johnd0e pushed a commit to IITC-CE/ingress-intel-total-conversion that referenced this pull request Apr 29, 2019
@johnd0e
Copy link

johnd0e commented Apr 29, 2019

a52cbaf

Nice job!

@modos189
Copy link
Author

Maybe you'll be able to finish options.padding support. Ornaments are constantly shifting: either by moving the map or changing the screen size

@johnd0e
Copy link

johnd0e commented Apr 30, 2019

Ornaments are constantly shifting

We need padding to solve this, or this issue caused by unfinished padding support?

@modos189
Copy link
Author

modos189 commented Apr 30, 2019

It's not ready. Maybe I should have sent it to a separate branch.
Padding is needed to draw portals that are outside the visible part of the screen, but close to it, just like in Leaflet and IITC. I have implemented this, but there are some conflicts when moving the map. Ornaments move more than portals.

@johnd0e
Copy link

johnd0e commented Apr 30, 2019

As this feature is not blocker it makes sense to put it separate branch.

And tell me more about 419b1ab: what is 'atypical use'?

@modos189
Copy link
Author

modos189 commented Apr 30, 2019

I was able to fix it. Padding works correctly.

what is 'atypical use'?

Our code tries to remove those markers which may not exist.

https://github.com/IITC-CE/ingress-intel-total-conversion/blob/256f9c53a866a254b40e40b1f766e58b4d2a89f4/code/ornaments.js#L69-L73

That's why I added additional checks to correct the errors.

@johnd0e
Copy link

johnd0e commented Apr 30, 2019

I was able to fix it. Padding works correctly.

Great!
But check upper comment please ^^^:

// e.g. 0.1 would be 10% of map view in each direction
padding: 0.1
},

Copy link

@johnd0e johnd0e Apr 30, 2019

Choose a reason for hiding this comment

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

Shouldn't we inherit this value from map renderer?

Copy link
Author

Choose a reason for hiding this comment

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

In Leaflet padding value is specified in Renderer class (var Renderer = Layer.extend({) and is not overridden.
It would be useful to assign an indent equal to that in window.map in iitc, but this is hardly possible.

Copy link

@johnd0e johnd0e May 3, 2019

Choose a reason for hiding this comment

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

It would be useful to assign an indent equal to that in window.map in iitc, but this is hardly possible.

Why hardly? I suppose we just need map._renderer.options.padding.
Or map.getRenderer({options:{}}).options.padding.

Then in our boot.js we can do like this:

L.CanvasIconLayer.mergeOptions({
  padding: map._renderer.options.padding`
});

@@ -24,7 +24,8 @@ function layerFactory(L) {
this._draw();
},
onRemove: function () {
this._destroyContainer();
// TODO
// this._destroyContainer();
Copy link

Choose a reason for hiding this comment

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

Call this._destroyContainer() is unique to this plugin and redundant

Currently L.CanvasMarkerLayer has dual nature:

  • L.Layer, from which it's inherited initially.
  • And after Spaction@153525e it has some features of L.Renderer (but still is not inherited from it)

I can guess that mentioned commit was just a step to make true renderer which can be used transparently (#2).
But in it's current (perhaps unfinished) state L.CanvasMarkerLayer is rather layer, so it should'n destroy it's container on remove.

I wonder if we've chosen right fork to continue..

@johnd0e
Copy link

johnd0e commented May 1, 2019

Our code tries to remove those markers which may not exist.

removeMarker was broken anyway.

Also I am going to fix our code, so we do not need additional checks in upstream.

Although, those checks may make sense in general (but not in this branch).

johnd0e pushed a commit that referenced this pull request May 1, 2019
@johnd0e
Copy link

johnd0e commented May 1, 2019

@modos189
I am going to clean up and rewrite this branch, tell me when you ready.
Separate branches for all features already created (todo: a52cbaf)

@johnd0e
Copy link

johnd0e commented May 2, 2019

Please check comments regarding padding option.
I have implemented fixes in padding-option branch, but not tested yet.

@johnd0e
Copy link

johnd0e commented May 2, 2019

My fault, thank you for pointing out.

@modos189
Copy link
Author

modos189 commented May 2, 2019

I saw you similar change in padding-option branch. But there is an error: instead of layerPointToContainerPoint you should use containerPointToLayerPoint

@johnd0e
Copy link

johnd0e commented May 3, 2019

I saw you similar change in padding-option branch

I've just updated that branch with your last commit.
Let's continue padding-related development there.

@johnd0e
Copy link

johnd0e commented May 3, 2019

As all needed for IITC features are now separated between own branches, all we need - merge them together, like this:

git checkout master
git checkout -b changes-for-IITC
git merge --no-ff fixes canvas-resize layer-features-back padding-option
git push --force

I've already done this in test branch, and about to rewrite changes-for-IITC branch with the content of test.

All future updates should go to feature branches, here we'll need merge them together only.

P.S.
And I suppose we need to open corresponding PR's in Spaction's repo.

@johnd0e
Copy link

johnd0e commented May 6, 2019

@modos189
I finished with all branches except padding-option.

I am unable to check it, as I just do not understand how it should function.
Let's start from related issue: IITC-CE/ingress-intel-total-conversion#184

johndoe added 10 commits May 7, 2019 12:25
`this._markers` is undefined in `_searchPoints`, called from event listeners.
Now we check markers existence in the beginning of handlers.

Note 1:
Could be fixed in some another place:
 e.g. check `_markers` in `_searchPoints`
 ...or initialize (empty) `_markers` on CanvasMarkerLayer init

Note 2:
`!this._map` removed from condition in `_onMouseMove:` 'cause
it's never should be true as we detach listeners on remove from map
Original intentions of that refactoring is not clear,
perhaps it was intermediate step before transforming into true Renderer.

But in current state it is not actually Renderer, so we need to revert some parts,
to continue using it as independent Layer.

Notes:
  `CanvasMarkerLayer` is still independent entity which does not fit flawlessly into Leaflet ecosystem.
  It would be much more convenient if instead of `CanvasMarkerLayer` we have `CanvasMarker`,
  able to be used as direct and transparent replacement for `L.Marker`.
  Though currently I am not sure how to do it best:
  - may be we need dedicated Renderer class
  - or may be it can be simpler, and all we need - `CanvasMarker` inherited from `L.Path`.
Was protected in marker add time, but not on zoom/pan

Sample:
```
VM2992:16252 Uncaught DOMException: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The HTMLImageElement provided is in the 'broken' state.
    at NewClass._drawImage (<anonymous>:16252:23)
    at NewClass._drawMarker (<anonymous>:16239:22)
    at <anonymous>:16200:22
    at Array.forEach (<anonymous>)
    at NewClass._draw (<anonymous>:16179:16)
    at NewClass._redraw (<anonymous>:16077:18)
    at NewClass.fire (<anonymous>:1867:11)
    at NewClass._move (<anonymous>:5506:9)
    at NewClass._onZoomTransitionEnd (<anonymous>:5963:8)
```
This was originally meant but missed (see _full.js / _standalone.js)
@modos189
Copy link
Author

It's all working now.

@johnd0e
Copy link

johnd0e commented May 22, 2019

@modos189
I am not sure that 2 latest commits are needed.
See test branch (as I said in previous message)

@modos189
Copy link
Author

modos189 commented May 22, 2019

In IITC-CE/ingress-intel-total-conversion#181 which branch is being used? I used that version and I thought it was from test branch

up: Indeed, these changes already exist in the test branch

@modos189 modos189 marked this pull request as ready for review May 22, 2019 18:31
@johnd0e
Copy link

johnd0e commented May 22, 2019

Do you still need this branch? If not then I will rewrite it with actual commits.

@modos189
Copy link
Author

No, you can rewrite

@johnd0e
Copy link

johnd0e commented May 24, 2019

Please check this comment: 71eab75#commitcomment-33502466

@modos189
Copy link
Author

modos189 commented Jun 27, 2019

I'm totally confused in branches, so I created a new branch for onresize method: https://github.com/IITC-CE/Leaflet.Canvas-Markers/tree/onresize

Merge after this: #1 (comment)

@johnd0e
Copy link

johnd0e commented Jun 29, 2019

I'm totally confused in branches

We have independent branch for every new feature here. We keep it so it will be easy to make PR's to parent repo in the future.

And all that branches merge together here, in changes-for-IITC - it is not independent branch.

So to complete our work here we should finish last branch, for what we have concerns: padding-option.
I think it is not ok, check comments for f451114

@modos189
Copy link
Author

modos189 commented Jul 9, 2019

@johnd0e 1d88dcf

@johnd0e
Copy link

johnd0e commented Jul 10, 2019

@johnd0e 1d88dcf

Good! But see question there.

Also question about _updateTransform left unanswered in f451114

johnd0e pushed a commit that referenced this pull request Jul 11, 2019
@johnd0e johnd0e closed this Sep 28, 2019
@johnd0e johnd0e deleted the changes-for-IITC branch September 28, 2019 15:56
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