Comments (2)
This can be easily accomplished in a number of ways. In order of ease and complexity descending, I would recommend the following approaches:
-
Define your various markers as an array of
IMarkerIconInfo
. In yourx-map
, usengFor
in conjunction withx-map-marker
to create your markers. Bind theIconInfo
property of the marker to a method calledGetMarkerInfo(): IMarkerIconInfo
or some such. Implement this method in your component class to return the appropriateIMarkerIconInfo
from your array ofIMarkerIconInfo
. You can pass any iteration variables into that method to implement the logic to select the appropriateIMarkerIconInfo
. -
Define your various markers as an array of
IMarkerIconInfo
. Sort your markers into different arrays, one array for each color. Use ax-map-layer
for each color and use anngFor
inside each layer withx-map-markers
and the appropriate array for the color to render your markers. Each marker would use the appropriate positional element of your array ofIMarkerIconInfo
. The example at https://plnkr.co/XAokXU shows this approach. -
Use
x-map-maker-layer
component (particularly if you have thousands of markers). It works a bit different and takesMarkerOptions
as an input. This input expects an array of typeIMarkerOptions
(one for each marker), which in turn has anIMarkerIconInfo
representing the icon for each marker. An example for this is at http://plnkr.co/bb8wu5 (you got to click to populate the markers).
Note that for all these, when you assemble your IMarkerIconInfo
, make sure you set the id
property of the IMarkerIconInfo
. It is a string and you can make it whatever you want it to be, but is has to uniquely identify the marker image (so your red marker must have a different id from from green marker etc.). If you do not set this property, then for each marker, we will generate an entirely new image, which with a large number of markers is very costly. If you set the id, we will look up already created images that match that id, which is a lot more performant...
Happy coding.
from angular-maps.
Hi @thor-schueler I went with the second approach and it solved my problem.
This is exactly what i was looking for.
Thank you very much for you quick help. 👍
from angular-maps.
Related Issues (20)
- Unhandled Promise rejection by Zone.js Error in Angular7 HOT 1
- How can I add get current location functionality
- use new Microsoft.Maps.DrawingTools with angular-maps HOT 6
- x-map-polygon events (moving a polygon point or creating a new point) HOT 1
- Show current location functionality with circle around the location HOT 1
- trigger MouseDown in x-map-polygon HOT 1
- Not updated polygon after add a point in the Paths
- Help use BingMapService HOT 1
- Cannot change Bingmaps height/width HOT 1
- BoundsChange emits wrong value
- Marker events does not trigger
- Font Awesome 5 not working
- Angular-Maps not working in Angular 9 HOT 9
- Spider cluster marker dynamic data loading issue
- x-map-polyline [Paths] are not working
- multilayer markers dynamic update not working
- CreateMap() this._loader.Load is not a function
- Image overlay
- Can I dynamically change keys for map? And switch map provider as well?
- Cannot read properties of undefined (reading 'nativeElement')
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 angular-maps.