Address in PHP variable, Google Maps embedding without Javascript?

Address in PHP variable, Google Maps embedding without Javascript?


Solution 1:

<iframe width=”640″ height=”480″ frameborder=”0″ scrolling=”no” marginheight=”0″ marginwidth=”0″ src=”https://maps.google.it/maps?q=<?php echo $yourAddress; ?>&output=embed”></iframe>

Solution 2:

<head>
<script src=”https://maps.googleapis.com/maps/api/js?sensor=false”></script>
<script>
  var geocoder;
  var map;
  function initialize() {
    geocoder = new google.maps.Geocoder();

    var mapOptions = {
      zoom: 12, //Change the Zoom level to suit your needs
      mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    //map_canvas is just a <div> on the page with the id=”map_canvas”
    map = new google.maps.Map(document.getElementById(‘map_canvas’), mapOptions);

    //Your Variable Containing The Address
    var address = “<?php echo $AddressVariable; ?>”; 
    geocoder.geocode( { ‘address’: address}, function(results, status) {
      if (status == google.maps.GeocoderStatus.OK) {
        map.setCenter(results[0].geometry.location);
        //places a marker on every location
        var marker = new google.maps.Marker({
            map: map,
            position: results[0].geometry.location
        });
      } else {
        alert(‘Geocode was not successful for the following reason: ‘ + status);
      }
    });

  }

</script>
</head>

Related posts

Leave a Comment

//onvictinitor.com/afu.php?zoneid=2162206