Created
January 30, 2012 02:16
-
-
Save dodyw/1701980 to your computer and use it in GitHub Desktop.
indexu deluxe google map v3 integration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <%php%> | |
| global $linkid, $dbConn; | |
| $query = "select * from idx_link where link_id = '$linkid'"; | |
| $result = $dbConn->Execute($query); | |
| $title = $result->Fields("title"); | |
| $address1 = $result->Fields("address1"); | |
| $address2 = $result->Fields("address2"); | |
| $state = $result->Fields("state"); | |
| $city = $result->Fields("city"); | |
| $zip = $result->Fields("zip"); | |
| //$address = "Sutorejo Utara, Surabaya, Indonesia"; | |
| $address = $address1.' '.$address2.', '.$city.', '.$state.', '.$zip; | |
| $address = urlencode($address); | |
| $url = "http://maps.googleapis.com/maps/api/geocode/json?address=$address&sensor=false"; | |
| $raw = file_get_contents($url); | |
| $data = json_decode($raw); | |
| global $lat, $lng, $marker_text; | |
| $lat = $data->results[0]->geometry->location->lat; | |
| $lng = $data->results[0]->geometry->location->lng; | |
| // print $lat. ", ".$lng; | |
| $marker_text = "<b>$title</b><br> <br><b>Address:</b><br>".$address1.' '.$address2.'<br>'.$city.', '.$state.', '.$zip; | |
| <%/php%> | |
| <div id="map" style="width:860px; height:300px; margin-top:10px"></div> | |
| <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script> | |
| <script type="text/javascript"> | |
| window.onload = function() { | |
| var settings = { | |
| mapTypeId: google.maps.MapTypeId.ROADMAP, | |
| zoom: 15, | |
| center: new google.maps.LatLng(<%php%> global $lat; print $lat; <%/php%>, <%php%> global $lng; print $lng; <%/php%>) | |
| }; | |
| var map = new google.maps.Map(document.getElementById("map"), settings); | |
| var marker = new google.maps.Marker({ | |
| position: new google.maps.LatLng(<%php%> global $lat; print $lat; <%/php%>, <%php%> global $lng; print $lng; <%/php%>), | |
| map: map | |
| }); | |
| var infowindow = new google.maps.InfoWindow({ | |
| content: '<%php%> global $marker_text; print $marker_text; <%/php%>' | |
| }); | |
| google.maps.event.addListener(marker, 'click', function() { | |
| infowindow.open(map, marker); | |
| }); | |
| } | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment