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

stylefunction.js use ol.js #78

Closed
songyumeng opened this issue Apr 13, 2018 · 4 comments
Closed

stylefunction.js use ol.js #78

songyumeng opened this issue Apr 13, 2018 · 4 comments

Comments

@songyumeng
Copy link
Contributor

songyumeng commented Apr 13, 2018

I saw some code in stylefunction.js which must use ol-debug.js because getFlatMidpoint is not an api function.
image
In ol/geom/LineString
image
If possible i want to use getCoordinateAt(0,5) instead of getFlatMidpoint() because getCoordinateAt is an api function.

@ahocevar
Copy link
Member

getCoordinateAt() is too slow, because it recalculates the coordinate with every call. Isn't it possible for you to use the ol package?

@songyumeng
Copy link
Contributor Author

Sorry, I didn't notice getFlatMidpoint has a cache.
I use ol.js , neither ol package nor ol-debug.js , and in my project icon-image is not displayed.
How about this , if there is getFlatMidpoint function,use it,otherwise use getCoordinateAt(0,5),then all people who use ol.js can use image-icon .

image

@ahocevar
Copy link
Member

Most users will use the default ol.render.Feature tile class with vector tiles, which does not have a getCoordinateAt() method. I'd suggest you either use the ol package, or modify the ol.geom.LineString prototype to provide a getFlatMidpoint method, such as

ol.geom.LineString.prototype.getFlatMidpoint = function() {
  return this.getCoordinateAt(0.5);
};

You can do this in your application before using any of ol-mapbox-style's functions.

@songyumeng
Copy link
Contributor Author

OK.Thank you.

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

No branches or pull requests

2 participants