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

Question about Marker Window when bound to data #132

Closed r1randy closed 7 years ago

r1randy commented 7 years ago

First of all, thanks for the great API!

I have been following your examples. When I got to the example 'Binding to a Model', I have everything working except for the marker window. The info I am sending from my controller is showing up as sequential text above the map, instead of in the Window when you click on a marker. I suspect I am using the wrong data type for 'InfoWindowContent' in your example? I am just passing a string at the moment.

Below is the section of the view I am having trouble with:

marker.Window = new InfoWindow(marker)
        {
            Template =
            {
                Content = () => ViewContext.Writer.Write(regionInfo.InfoWindowContent)
            }
        };
jmelosegui commented 7 years ago

Can you confirm you are ending the helper declaration with a Render() method?

@{
    Html.GoogleMap()
        .Name("map")
        .Height(600)
        .BindTo<RegionInfo, Marker>
...
                            , new Size(18, 12)
                                , new Point(0, 0)
                                , new Point(0, 12));
                            marker.Window = new InfoWindow(marker)
                            {
                                Template =
                                {
                                    Content = () => ViewContext.Writer.Write(regionInfo.InfoWindowContent)
                                }
                            };
                        }
                    )
            )
        ).Render();
}
r1randy commented 7 years ago

Wow, thanks for the fast response! The .Render() was showing up as text at the bottom of the map. I missed bracketing the map section with {} and had:

@(Html.GoogleMap()
....
    ).Render();
)

I knew it was something simple. Thanks again!