Created
July 10, 2014 09:24
-
-
Save tobbbe/4f1a01bb96fdbb719082 to your computer and use it in GitHub Desktop.
google maps iframe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@{ | |
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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment