3
<script type="text/javascript" src="http://maps.google.com/maps/api/js?key=AIzaSyDUZgjcLfmsJUX7oKmJhG_jqJK_gK0xkng"></script>
<body onload="initialize();">
<?php
$geocode=file_get_contents('http://maps.google.com/maps/api/geocode/json?address='.urlencode($imovel->endereco).'&sensor=false');
$output= json_decode($geocode);
if($output->status === 'ZERO_RESULTS'){
} else {
$lat = $output->results[0]->geometry->location->lat;
$long = $output->results[0]->geometry->location->lng;
?>
<script type="text/javascript">
var marker;
function initialize() {
var myLatlng = new google.maps.LatLng(<?php echo $lat; ?>, <?php echo $long; ?>);
var myOptions = {
zoom: 15,
center: myLatlng,
scrollwheel: false,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("mapa"), myOptions);
marker = new google.maps.Marker({
position: myLatlng,
map: map,
icon: "imagens/flag.png"
});
var infowindow = new google.maps.InfoWindow({
content: "<?php echo $imovel->endereco; ?>"
});
google.maps.event.addListener(marker, 'click', function(){
infowindow.open(map,marker);
});
}
</script>
<?php } ?>
<div id="mapa"></div>
</body>
What is your difficulty in this code? It would be interesting to edit the question and provide more details.
– user28595
In the code itself there is no error. But I don’t want the map to have a specific location, but it has a radius of about 2 kg around the location that will be indicated.
– Beatriz de Almeida
Put this comment explanation in the text of your question describing what you have already tried and if possible an image of the final result on the map. This increases your chances of response. Take the opportunity to fix the drive distance that seems to be "Km" =)
– Pagotti
Thanks! I had already tried to edit the question and my comment, but is not editing :/
– Beatriz de Almeida
The comment you will not be able to edit (after a while it can only be deleted), already, the question, this can be edited by clicking here.
– Daniel
Your image made the question clear @Beatriz, but did you try something that could strengthen your question? A code or some example. Welcome to Stackoverflow, I recommend reading on tour to understand a little more how the site works.
– Marconi