Jump to content

justdima

New Members
  • Posts

    1
  • Joined

  • Last visited

justdima's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi there, I am having a small problem getting php to work with google maps APIs. Basically, I have an API url where I pull down lat/long coordinates from for 10 houses and then I want these to map out on the google maps. So, I am not sure how to link the 2 together.. Here is what I have so far: <?php // Loading Domus API $url_search = 'http://url/site/go/api/search'; $xml_search = @simplexml_load_file($url_search) or die ("no file loaded") ; //Displaying latitude and longutude $xml_search = json_decode($xml_search); foreach($xml_search->property as $house) { echo $lat = $house->address->latitude , $long = $house->address->longitude; }; ?> and JavaScript bit: var locations = [ ]; var map = new google.maps.Map(document.getElementById('map'), { zoom: 10, center: new google.maps.LatLng(-33.92, 151.25), mapTypeId: google.maps.MapTypeId.ROADMAP }); var infowindow = new google.maps.InfoWindow(); var marker, i; for (i = 0; i < locations.length; i++) { marker = new google.maps.Marker({ position: new google.maps.LatLng(locations[i][1], locations[i][2]), map: map }); google.maps.event.addListener(marker, 'click', (function(marker, i) { return function() { infowindow.setContent(locations[i][0]); infowindow.open(map, marker); } })(marker, i)); } Many thanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.