Comments (5)
PS Just noticed this thread is two and a half years old! 🙀
from ember-google-maps.
@estshy to do that, your best bet would probably be to take advantage of the addon system implemented in #17
You should be able to end up with a template that looks something like this:
{{#g-map lat="51.508530" lng="-0.076132" as |g|}}
{{g.markerCluster markers=(your array of positions here)}}
{{/g-map}}
To do that, you'll need to generate an addon (or an in-repo addon if #38 lands). Take a look at https://github.com/sandydoo/ember-google-maps-sample-addon/blob/master/addon/components/g-map-addons/sample-addon.js for an example of what you can do.
Once you've got your components loading up, you'll have access to the existing map and be able to do what you want.
from ember-google-maps.
@estshy, I'm not convinced I implied that you should use overlays instead of clustering 😅
We don't yet have a clustering component, but I think it's worth adding. Going to add this request towards the next release.
You can try following @acorncom suggestions, but there isn't any concrete documentation other than a sample addon implementation.
from ember-google-maps.
I have looked into clusterizing vanilla markers (not custom overlays), and turns out that adding this feature to the addon is quite challenging.
I doubt that it can be done with an ember-google-maps-addon without heavily modifying the core addon:
- the clusterer has to be initialized on the map level;
- the markers must have a reference to the clusterer;
- lots of options must be exposed to allow clusterer configuration;
- etc.
On the other hand, clusterizing in the userland is quite easy. The sample below is written from my head, might need adjustments to actually work:
import MarkerClusterer from '@googlemaps/markerclustererplus';
{
@action
onLoad({map, components: {markers}}) {
new MarkerClusterer(
map,
markers: markers.map(item => item.markers),
{
// Should correspond to app.import in ember-cli-build.js
imagePath: 'assets/images/google-maps-clusterer/m',
}
);
}
}
// ember-cli-build.js
const fs = require('fs');
const path = require('path');
const clustererImagesPath = 'node_modules/@googlemaps/markerclustererplus/images';
fs.readdirSync(clustererImagesPath).forEach(file => {
const fileFullPath = path.join(clustererImagesPath, file);
app.import(fileFullPath, {
destDir: 'assets/images/google-maps-clusterer'
});
});
I don't know if https://github.com/googlemaps/js-markerclustererplus can be retrofitted to clusterize custom overlays. Maybe Glimmer components can be duck-typed to mimic as markers... In the worst case, this lib can be ported into the Ember land, and it doesn't necessarily have to be hardwired into ember-google-maps
.
from ember-google-maps.
I have looked into clusterizing vanilla markers (not custom overlays), and turns out that adding this feature to the addon is quite challenging.
https://github.com/sandydoo/ember-google-maps-markerclustererplus is almost ready. Should be plug-n-play with ember-google-maps 🤞
Is there anything similar (clustering) that can be used as replacement for overlays
AFAIK there is no ready-made solution for this. I reckon the clustering library will likely accept an overlay view that mimics a marker. But don't quote me on that.
This feature is out of the scope of this addon, unless someone is generous enough to fund it.
from ember-google-maps.
Related Issues (20)
- Glimmer components HOT 14
- Upgrade ember-concurrency to version 2.x HOT 2
- Versions of modifier manager capabilities prior to 3.22 have been deprecated.
- Breaking change regarding @lng @lat HOT 3
- Canary tests failing because of `@ember/test-helpers`
- Error: Could not find module `@ember/test-waiters` imported from `ember-google-maps/component-managers/map-component-manager` HOT 2
- pauseTestForIdle function causes tests failing with timeout HOT 4
- Add section about testing to docs
- Map component does not watch lat and lng for changes HOT 2
- Ember 4.0 requires ember-auto-import >= 2 HOT 1
- Convert to addon v2 format HOT 2
- Maps in demo page do not work currently HOT 1
- There are error messages in CI
- Build fails with `staticComponents: true` under Embroider HOT 4
- The directions example is broken HOT 1
- Ember 3.24 compatibility conflict HOT 1
- Acceptance test fails on beta and canary
- Quick Question: Traffic Layers HOT 10
- The use of the private {{-in-element}} is deprecated HOT 1
- Autocomplete stops working on subsequent route visits HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ember-google-maps.