google maps iframe
@{
var longitude = Location.Longitude.ToString() ?? null;
var latitude = Location.Latitude.ToString() ?? null;
var googlemapSource = "https://www.google.com/maps/embed/v1/";
if (!string.IsNullOrEmpty(latitude) && !string.IsNullOrEmpty(longitude))
{
// map mode
googlemapSource += "place?";
// cordinates / adress (has to use a dot not comma...)
longitude = longitude.Replace(",", ".");
latitude = latitude.Replace(",", ".");
googlemapSource += "&q=" + longitude + "+" + latitude;
// zoom level
googlemapSource += "&zoom=" + "10";
}
else
{
// map mode
googlemapSource += "view?";
// default location
googlemapSource += "center=" + "39.60342576096072,2.9043215749999978";
// zoom level
googlemapSource += "&zoom=" + "8";
}
// API key
googlemapSource += "&key=" + "AIzaSyAVn6ea2iJcMq9Wp0pKGlr3RpA8SVK1MCM";
// map type: roadmap or satellite
googlemapSource += "&maptype=" + "roadmap";
}
<iframe
width="100%"
height="280"
frameborder="0"
style="border:0"
scrolling="no"
src="@googlemapSource"
></iframe>