Comments (5)
Could you provide sample of code?
from blazorgooglemaps.
<GoogleMap @ref="@map1" Id="map1" Options="@mapOptions">
@code {
private GoogleMap map1;
private MapOptions mapOptions;
private List markers;
private List _events = new List();
private LatLngBounds bounds;
private List polylines = new List();
private Polyline polyline;
async Task AddMarkers(List records)
{
for (int i = 0; i < records.Count; i++)
{
var markerPosition = new LatLngLiteral { Lat = TelematicsRecords[i].Latitude, Lng = TelematicsRecords[i].Longitude };
var marker = await Marker.CreateAsync(map1.JsRuntime, new MarkerOptions()
{
Position = markerPosition,
Map = map1.InteropObject,
Label = $"{i}",
ZIndex = records.Count,
Visible = true,
Icon = "http://maps.google.com/mapfiles/ms/icons/purple-dot.png"
});
markers.Add(marker);
}
}
This adds the markers, how do I remove them? I tried setting markers = null, and doesn't work.
from blazorgooglemaps.
You should track marker which you want to remove. You could use marker Guid propert.
In your example to remove first marker you could do
var firstMarker = markers.FirstOrDefault();
await firstMarker.SetMap(null);
from blazorgooglemaps.
You could check example
https://github.com/rungwiroon/BlazorGoogleMaps/blob/master/ServerSideDemo/Pages/MapMarker.razor.cs
from blazorgooglemaps.
Closing.
from blazorgooglemaps.
Related Issues (20)
- Adding Blazor Custom Elements on to the map HOT 7
- oderv 10000 Markers HOT 1
- Warnings about deprecated fields due to `JSON.stringify` usage HOT 6
- Problem With .net 8 WebApp HOT 1
- Not able to run a Blank Project with GoogleMapsComponents HOT 1
- No RectangleList? (Cannot add previously saved Rectangle to map)
- Multi framework support
- Need server side demo with testing all components
- Did you have already Geolocation Support? HOT 3
- Need API documentation and support on Stack Overflow HOT 6
- Accessing the map object via javascript HOT 4
- Working with encoded polylines. HOT 2
- Multiple Ground Overlays HOT 3
- DrawingManager.SetDrawingMode no longer works in 3.3.2 and newer HOT 7
- Add class DragEndEvent for dragend listener (Suggestion) HOT 1
- MarkerClustering - Set Click on Zoom level; HOT 2
- polygonList not rendering the polygons HOT 9
- Advanced Markers server side demo dont work anymore HOT 4
- Link KeyProvider to map object scope instead of application level static HOT 2
- Advanced Marker Support HOT 4
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 blazorgooglemaps.