Coder Social home page Coder Social logo

Comments (8)

valentasm1 avatar valentasm1 commented on August 11, 2024

Could you check this guy post. I think he has implemented your requirements. Let me know if it helped.
#49

from blazorgooglemaps.

Essum13 avatar Essum13 commented on August 11, 2024

I did check all the previously Issues before. Maybe one option for me would be to instead of opening a infowindow, opening a modal and then style that.

Do you understand what i wanted to achive in the first place? In my perfect world i wanted to create my marker with my infowindow, adding a listener for that infowindow and whenever it´s "domready", apply some styling. Like this:

public InfoWindow infoWindow = null;

var marker = await Marker.CreateAsync(map.JsRuntime, new MarkerOptions()
                    {
                        Position = new LatLngLiteral { Lat = klev.Latitude, Lng = klev.Longitude },
                        Map = map.InteropObject,
                        Icon = ""
                    });

var infoWindowContent = "infowindowcontent";

 await marker.AddListener("click", async () =>
                    {
                        infoWindow = await InfoWindow.CreateAsync(map.JsRuntime);

                        await infoWindow.SetContent(infoWindowContent);
                        await infoWindow.SetPosition(await marker.GetPosition());
                        await infoWindow.Open(map.InteropObject);
                    });

/// this is what i would like to add:

google.maps.event.addListener(infoWindow, 'domready', function() {

   do stuff here.
});

Another thing i wonder which falls into the same category. Is it possible to add domListener to the map div? Didn´t find anything on this either. It´s done here in this example: https://developers.google.com/maps/documentation/javascript/examples/event-domListener

from blazorgooglemaps.

RobertoMilani avatar RobertoMilani commented on August 11, 2024

@Essum13
I found this:
https://stackoverflow.com/questions/5416160/listening-for-the-domready-event-for-google-maps-infowindow-class

And this:
https://developers.google.com/maps/documentation/javascript/reference/info-window

Where is explained that:
image

So, it is implemented in Google Maps API, yes!

Now, you are right: our implementation of InfoWindow leaks a:

public async Task<MapEventListener> AddListener(string eventName, Action handler)

implementation, so if @valentasm1 believe can be usefull, I can provide the update of InfoWindow class coherent with the same method inside Marker class (seems me underlying objects are already resilient to it).

from blazorgooglemaps.

valentasm1 avatar valentasm1 commented on August 11, 2024

@RobertoMilani np. You could do it. This functionality wont break all system. Just on extra method. Thank you so much.

from blazorgooglemaps.

RobertoMilani avatar RobertoMilani commented on August 11, 2024

@valentasm1 Ok, I'll do just after my "work time" ;)

@Essum13 if you want, however, due the "static behaviour" on InfoWindow (in which are injected static HTML), in a personal project I successfull mapped a "click" event on marker that cause the open of a Bootstrap modal with dynamic content (inside modal I put a custom Blazor component initialized by parameters that render a specific content of which marker Guid is only one on them (parameters)). I can share example code fragments if you like / need.
Anyway InfoWindow needs a AddListener method, I only suggest you to think "wider" -> a "static" content may be really your "target" or not (please, do not interpret my words as opinionated, it is not my intention :) )

A note:
I've not yet experimented things like JQuery HTML creation and injection inside a InfoWindow. I suppose it can be done, giving, for instance a unique id to a DIV that is used as InfoWindow content;, after several months of Blazor experience, it's for me a kind of "old way" approach and it is not the first things I have in mind to obtain a popup with dynamic content shown in response of a marker click event :)

from blazorgooglemaps.

valentasm1 avatar valentasm1 commented on August 11, 2024

PullRequest which should help to solve issue #55
and nuget
https://www.nuget.org/packages/BlazorGoogleMaps/0.6.10

from blazorgooglemaps.

valentasm1 avatar valentasm1 commented on August 11, 2024

Could i close issue?

from blazorgooglemaps.

Essum13 avatar Essum13 commented on August 11, 2024

Thanks, your implementation solved my problems. You can close the issue!

from blazorgooglemaps.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.