rungwiroon/BlazorGoogleMaps

New feature (Beta) Marker google.maps.CollisionBehavior

joe-shapiro-biz opened this issue · 32 comments

I wonder if you would please implement collisionBehavior in markeroptions or setCollisionBehavior on Marker. Thanks.

Do you have examples?

Could you double check link. It says "That page doesn't exist."

Aha. This looks doable.
I will try to do this in comming day, if you wont get update in week just ping me here.

thank you so much.

https://github.com/rungwiroon/BlazorGoogleMaps/releases/tag/1.0.16

   var marker = await Marker.CreateAsync(map1.JsRuntime, new MarkerOptions()
            {
                Position = mapCenter,
                Map = map1.InteropObject,
                Label = $"Test {markers.Count}",
                CollisionBehavior = CollisionBehavior.OPTIONAL_AND_HIDES_LOWER_PRIORITY
             
            });

Let me know if it works :).

on first try, seems to have no effect.

    static int z = 0;
    public async Task addPing(SxGpsPing ping)
    {


        var Position = new LatLngLiteral(ping.X, ping.Y);
        var tripCode = tripCodes[ping.AlternateTripId.Value];
        var color = colors[tripCode];

        var opts = new MarkerOptions()
        {
            Position = Position,
            CollisionBehavior = CollisionBehavior.OPTIONAL_AND_HIDES_LOWER_PRIORITY,
            ZIndex = z++,
            Map = _Map.InteropObject,
            Icon = pingIcon(color),
            Label = "\t" + ping.GpsTimeStamp.ToLocalTime().ToShortTimeString(),
            Title = "\t" + ping.GpsTimeStamp.ToLocalTime().ToShortTimeString() 

        };
        var mk = await Marker.CreateAsync(_Map.JsRuntime, opts);

        var p = new Ping();
        p.ping = ping;
        p.marker = mk;

        pings[tripCode].Add(p);
    }

2021-07-19

what does this mean: Need to set v=beta to make it work

It should be like

<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=YOUR_KEY_GOES_HERE&v=beta"></script>

sorry, no luck.

I really dont know. All looks like google in google example. I assume it could be some flag in managament console.
You could clone code and run server side sample MapMarker (server side have almost all possible demos) and then check how is set in after this line

if (propertyValue !== null && typeof propertyValue === "string" && propertyValue.indexOf("google.maps.CollisionBehavior") == 0) {

and in this method

createObject

in objectManager.js
Maybe make very simple local html demo for this functionality and then compare how blazor google maps sets and what is missing.

I could try to look more this or coming week, but if you reproduce functionality on small html demo then you could find fast.

Any update?

At least i could agree we both in same situation. Where it looks like it should work but it dont.
Ok i will check one more time too.

So, it does seem to work if you provide a MapId. Crazy.

Would you please add MapId to MapOptions?

also, it seem you have to supply an initial center in the map options.

and, maybe the map has to be vector style.

For me providing MapId, v=beta was enough. It was working in server side demo
I dont understand why map id it is so important
https://developers.google.com/maps/documentation/javascript/reference/map#MapOptions.mapId

Ahaaa it works when i provide mapid from google example "3a3b33f0edd6ed2a", but dont when i generate random.
So it should be related to google Maps Management page and your map api.
I am leaving it for you to find out.

Please when you find solution (regarding MapId) write it here. It will be usefull for someone else too.