I am trying to implement the GMaps 1.0.3 pl (
http://www.revo.wangba.fr/gmaps-presentation.html) in my ModX CMS, since all other Google Maps packages satisfying my needs were using the old API and/or they would not work for me. I am trying to output a map of a given location with a marker at that given location. Namely, I have a resource with the following content:
[[!Gmaps? &language=`de` &mapType=`HYBRID` &zoom=`16` &markers=`[[*id]]` &mkrLatLngTv=`[[!GeoLatLng? &address=`Street, City, Country`]]` &mapLatLng=`[[!GeoLatLng? &address=`Street, City, Country`]]`]]
Of course, instead of "Street, City, Country" I am using a real address. In order to get the latitude and longitude of a given address in that format, I am using the following snippet called GeoLatLng:
<?php
$address = str_replace (" ", "+", urlencode($address));
$details_url = "http://maps.googleapis.com/maps/api/geocode/json?address=".$address."&sensor=false";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $details_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = json_decode(curl_exec($ch), true);
// If Status Code is ZERO_RESULTS, OVER_QUERY_LIMIT, REQUEST_DENIED or INVALID_REQUEST
if ($response['status'] != 'OK') {
return null;
}
$geometry = $response['results'][0]['geometry'];
return $geometry['location']['lat'].','.$geometry['location']['lng'];
?>
Firstly, I tried just returning the latitude and longitude of my given location and it gave me the correct two numbers. I then added the &mapLatLng parameter in the snippet-call which correctly showed a map centered around my given address. Now I want to add a marker at that place but it doesn't work. I just want a marker without any fancy extras such as an info box, and I tried it by using the necessary parameters given in this example:
http://www.revo.wangba.fr/one-marker-one-map.html
However, no matter what parameters I use and how I specify them, it seems there just won't be any marker showing up. Am I doing something completely wrong?