Skip to content

Commit

Permalink
improve map
Browse files Browse the repository at this point in the history
  • Loading branch information
alyxbb committed Jun 12, 2024
1 parent fca0575 commit 8a884f3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 39 deletions.
45 changes: 7 additions & 38 deletions public/js/responsivemap.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,7 @@
/*global google:true placeName*/

$(document).ready(function () {
//Google Maps JS
//Set Map
function initialize() {
var uryLocation = new google.maps.LatLng(Lat, Lng);
var mapOptions = {
zoom: 15,
center: uryLocation
};

var map = new google.maps.Map(document.getElementById("map"), mapOptions);
//Callout Content
var contentString = placeName;
//Set window width + content
var infowindow = new google.maps.InfoWindow({
content: contentString,
maxWidth: 500
});

//Add Marker
var marker = new google.maps.Marker({
position: uryLocation,
map,
title: placeName
});

//Resize Function
google.maps.event.addDomListener(window, "resize", function () {
var center = map.getCenter();
google.maps.event.trigger(map, "resize");
map.setCenter(center);
});
}

google.maps.event.addDomListener(window, "load", initialize);
});
var map = L.map('map').setView([Lat, Lng], 15);
L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
}).addTo(map);
var marker = L.marker([Lat, Lng]).addTo(map);
marker.bindPopup("University Radio York").openPopup();
7 changes: 6 additions & 1 deletion views/contact.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
<meta property="og:description" content="At URY, radio is a two-way medium. Send us a message or find us on social media.">
<meta property="og:image" content="{{.PageContext.FullURL}}{{url "/images/open_graph-general.jpg"}}">
<meta property="og:url" content="{{.PageContext.FullURL}}{{url "/contact/"}}">
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css"
integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY="
crossorigin=""/>
{{end}}

{{define "content"}}
Expand Down Expand Up @@ -145,6 +148,8 @@ var placeName = "{{.PageContext.LongName}}";
var Lat = {{.PageContext.Gmaps.Lat}};
var Lng = {{.PageContext.Gmaps.Lng}};
</script>
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"
integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo="
crossorigin=""></script>
<script src='{{url "/js/responsivemap.js"}}?ver={{ .PageContext.CacheBuster }}'></script>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&key={{.PageContext.Gmaps.APIKey}}"></script>
{{end}}

0 comments on commit 8a884f3

Please sign in to comment.