This page can't load Google Maps correctly
I am trying to get map from address but there are appear some error like You have exceeded your request quota for this API in my console so can anyone help me to fix this.
My Javascript code look like below so please check and let me know if i am doing something wrong...
Thanks!
?php
$geocode = file_get_contents('http://maps.google.com/maps/api/geocode/json?address='.$address.'sensor=false');
$output = json_decode($geocode); //Store values in variable
//print_r($output);
if($output-status == 'OK'){ // Check if address is available or not
$latitude = $output-results[0]-geometry-location-lat; //Returns Latitude
$longitude = $output-results[0]-geometry-location-lng; // Returns Longitude
}
else {
echo "Sorry we can't find this location.Check the details again!";
}
?
script type="text/javascript"
jQuery(document).ready(function () {
// Define the latitude and longitude positions
var latitude = parseFloat("?php echo $latitude; ?"); // Latitude get from above variable
var longitude = parseFloat("?php echo $longitude; ?"); // Longitude from same
var latlngPos = new google.maps.LatLng(latitude, longitude);
// Set up options for the Google map
var myOptions = {
zoom: 14,
center: latlngPos,
mapTypeId: google.maps.MapTypeId.ROADMAP,
zoomControlOptions: true,
zoomControlOptions: {
style: google.maps.ZoomControlStyle.LARGE
}
};
// Define the map
map = new google.maps.Map(document.getElementById("map"), myOptions);
// Add the marker
var marker = new google.maps.Marker({
position: latlngPos,
map: map,
title: "Your Location"
});
});
/script
Topic google-maps map api Wordpress javascript
Category Web