Skip to content

Set Styling when creating a map in the view #7

@mikaelkarlsson-se

Description

@mikaelkarlsson-se

I've used this code to generate a map in the view that I then populate with a bunch of icons/positions (as example 5 in the docs). It works good but I won't get any of the settings that I would like to have, which I've set on the data type in back office. Styling most of all as I use Hotel instead of the standard styling.
Can I achieve this somehow?

@Html.Terratype(new Options {
	Provider = new Terratype.Providers.GoogleMapsV3(),
	MapSetId = 2,
	Zoom = 2,
	Position = new Terratype.CoordinateSystems.Wgs84("15,0")
})

foreach (var partner in mapModel.Partners)
{
	var name = partner.GetPropertyValue("partnerName");
	var url = partner.GetPropertyValue("websiteURL").ToString();
	var location = partner.GetPropertyValue<Terratype.Models.Model>("location");

	@Html.Terratype(
		new Options
		{
			MapSetId = 2
		}, location,
		@<text>
			<h4>@name</h4>
			@if (!string.IsNullOrEmpty(url))
			{
				<a href="@url" target="_blank">@url.Replace("http://", "").Replace("https://", "")</a>
			}
		</text>
	)
}

I used this code before with a good result accept for when I later wanted to center the map, then the interactivity went crazy..

        foreach (var partner in mapModel.Partners)
        {
            var name = partner.GetPropertyValue("partnerName");
            var url = partner.GetPropertyValue("websiteURL").ToString();
            var location = partner.GetPropertyValue<Terratype.Models.Model>("location");
            @Html.Terratype(
                new Options {
                    MapSetId = 2,
                    Zoom = 3
                }, location,
                @<text>
                    <h4>@name</h4>
                    @if (!string.IsNullOrEmpty(url))
                    {
                        <a href="@url" target="_blank">@url.Replace("http://","").Replace("https://","")</a>
                    }
                </text>
            )
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions