Reputation: 21
I'm somewhat of a newbie here but I understand that if you ask a question you have got to pick an answer.
I'm trying to add a google maps to a site with the <img>
tag in PHP. There may be mulitple markers on the maps which coincide with the address. My problem is that the markers are not showing up themselves. Can someone point me in the right direction as to what I am doing wrong and help me find a solution. I have read through the documentation on the google maps api but it is not clear how to do this with an address.
My code:
<?php
$markers = "&markers=color:green%7CAustralia";
$mapUrl = "http://maps.googleapis.com/maps/api/staticmapsize=550x200".$markers."&sensor=true";
echo "<img src='$mapUrl' />";
?>
This in theory should show me a map of Australia with a marker dropped however it does not seem to work. Also is it possible to dynamically add markers to maps this way with address?
eg. $markers = "&markers=color:green%7CAustralia";
$markers = $markers."&markers=color:green%7CAmerica";
Can someone point me in the right direction?
Upvotes: 2
Views: 3513
Reputation: 32645
<img class='group-google-maps-preview' src='http://maps.googleapis.com/maps/api/staticmap?center=" . urlencode($this->address) . "&zoom={$this->zoom}&size=600x300&sensor=true&markers=color:red|" . urlencode($this->address) . "'>
Upvotes: 6