When calling the function initMap() , which loads the card, it gives an error
google is not defined.
function:
function initMap(lat, lng, radius) { var myLatlng = new google.maps.LatLng(lat, lng); map = new google.maps.Map($("#map"), { center: myLatlng, zoom: 10, mapTypeId: google.maps.MapTypeId.ROADMAP }); var circle = new google.maps.Circle({ strokeColor: '#FF0000', strokeOpacity: 0.8, strokeWeight: 2, fillColor: '#FF0000', fillOpacity: 0.35, map: map, center: myLatlng, radius: radius, editable: true }); google.maps.event.addListener(circle, 'radius_changed', function() { $("#radius").attr("value", circle.getRadius() * 0.001); }); google.maps.event.addListener(circle, 'center_changed', function() { $("#google_lat").attr("value", parseFloat(circle.getCenter().lat())); $("#google_lng").attr("value", parseFloat(circle.getCenter().lng())); $("#lat_out").html(circle.getCenter().lat()); $("#lng_out").html(circle.getCenter().lng()); }); $("#radius").keyup(function(){ temp_radius = parseFloat(($(this).val()) * 1000); circle.setRadius(temp_radius); }); $("#radius").ready(function(){ $("#radius").val(5); }); $('#apply').click(function () { $("#wrap_for_map").attr('hidden', true); $("#google_lat").val(parseFloat(circle.getCenter().lat())); $("#google_lng").val(parseFloat(circle.getCenter().lng())); $("#google_radius").val(parseFloat(circle.radius)); }); $('#cancel').click(function cancel() { $("#wrap_for_map").attr('hidden', true); $("#google_lat").val(null); $("#google_lng").val(null); $("#radius").val(null); $("#google_radius").val(null) $('#lat_out').html(''); $('#lng_out').html(''); }); } Called the first time the page loads:
$(document).ready(function () { var google_lat = $("#google_lat").val(); var google_lng = $("#google_lng").val(); initMap(google_lat, google_lng, temp_radius);
new google.maps.Map- Grundy