jmelosegui / GooglemapMvc

The control wraps Google maps API simplifying the use of Google maps in ASP.NET MVC applications.
MIT License
116 stars 61 forks source link

Add Infowindow to markers that are databound from model #140

Closed Pugglewuggle closed 7 years ago

Pugglewuggle commented 7 years ago

What following this example, I want to add an infowindow to each marker.

http://www.jmelosegui.com/map/marker/DataBindingToModel

How can I do this? The .Content property of a Window doesn't have a setter and there are no constructors which allow me to pass in a string for the content when doing this:

binding => binding.ItemDataBound
                    (
                        (marker, obj) =>
                        {
                            marker.Latitude = obj.Points[0].Latitude;
                            marker.Longitude = obj.Points[0].Longitude;
                            marker.Icon = new MarkerImage("~/Content/icons/icon.png", new Size(20, 20), new Point(0, 0), new Point(0, 20));
                            **marker.Window = new InfoWindow(marker);**
                            **marker.Window.Content = "My Content";**
                            marker.Title = "Chicken";
                            marker.Clickable = true;
                        })
jmelosegui commented 7 years ago

Can you go to http://www.jmelosegui.com/map/marker/DataBindingToModel and click on the view tab and see if that code help you?

Pugglewuggle commented 7 years ago

Ah, I didn't see you use initialization lists. Thanks. I'll let you know if there's anything else.