Jump to content

Recommended Posts

Can someone tell me why this isn't working?

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title></title>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"></script>

<script language="Javascript" type="text/javascript">
//<!
var center="Denver, CO";
var item="italian|restaurant";
var radius="10000";
var max_results="25";
var scriptname="places.php";

var map=null,markers=[],infowindow=null,refcache=[],detailcache=[];
    
function Initialize() {

	$.get(scriptname+'?search',{},function(data){
		results=[];
		try {
			eval('data='+data+';');
			if (data.status=='OK' && data.results.length) {
				results=data.results;
			}
			gotGeocoder(data.location);
		} catch (e) {}

		gotResults(results);
	});

	map = new google.maps.Map(document.getElementById('gmap_area'), {
		mapTypeControl: true
		,mapTypeControlOptions: {
			style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR
			,position: google.maps.ControlPosition.LEFT_TOP
		}
		,zoom: 10
		,center: new google.maps.LatLng(0, 0)
		,draggableCursor: 'crosshair'
		,draggingCursor: 'pointer'
		,panControl: true
		,panControlOptions: {position: google.maps.ControlPosition.LEFT_CENTER}
		,zoomControl: true
		,zoomControlOptions:{position:google.maps.ControlPosition.LEFT_CENTER}
		,overviewMapControl:true
		,overviewMapControlOptions:{opened:false}
		,disableDoubleClickZoom:true
		,streetViewControl: true
		,streetViewControlOptions:{position: google.maps.ControlPosition.LEFT_BOTTOM}
		,styles: [{ visibility: "on" }]
		,mapTypeId:google.maps.MapTypeId.HYBRID
	});

	infowindow=new google.maps.InfoWindow();
}
    
function gotGeocoder (geolocation) {
	map.setCenter(new google.maps.LatLng(geolocation.lat, geolocation.lng));
}

function gotResults(results) {
    
	for(i=0;i<markers.length;i++)
		markers[i].setMap(null);

	var bounds=new google.maps.LatLngBounds();
	var result_to_display=results.length;
	if (result_to_display>max_results) result_to_display=max_results;
	var html='';

	for (i=0; i<result_to_display; i++) {
		var result = results[i];

		html+='<div class="result">';
		html+='<div class="result-name"><a target=_blank onmouseover="goToPlace('+"'"+result.reference+"'"+',this)">'+result.name+'</a></div>';
		html+='<div class="vicinity">'+result.vicinity+'</div>';
		html+='<div class="direction"><a target=_blank href="'
			+'https://www.google.com/maps?source=uds&daddr='+result.vicinity+'('+result.name+')@'+result.geometry.location.lat+','+result.geometry.location.lng+'&saddr='+center
			+'">direction</a></div>';
		html+='</div>';

		var options={
			map:map
			,position:new google.maps.LatLng(result.geometry.location.lat, result.geometry.location.lng)
		};

		var marker=new google.maps.Marker(options);

		marker.content='<p>'+result.name+'</p><p>'+result.vicinity+'</p>';

		bounds.extend(marker.getPosition());

		google.maps.event.addListener(marker, 'click', function() {
			infowindow.setContent(
				this.content
			);
			infowindow.open(map,this);
		});

		markers.push(marker);
	}

	$('#searchcontrol').html(html);

	if (results.length)
		map.fitBounds(bounds);
}

function gotReference (data,a) {
	var content=$(a).html();
	var parent=$(a).parent();
	parent.html('<a href="'+data.url+'" target=_blank>'+content+'</a>');
}

function goToPlace (reference,a) {
	var index=refcache.indexOf(reference);
	if (index===-1)
		$.get(scriptname+'?reference='+reference,{},function(data){
			result={};
			try {
				eval('data='+data+';');
				if (data.status=='OK' && data.result) {
					result=data.result;
				}
				refcache.push(reference);
				detailcache.push(result);

			} catch (e) {}
			gotReference(result,a);
		});
	else {
		gotReference(detailcache[index],a);
	}
}

$(document).ready(function(){
	Initialize();
});

//]]>
</script>
<style>
	.localexample{width: 40%;height: 100%;float: left;}
	.localexample strong{display: block;border-bottom: 1px dotted #ccc;margin-bottom: 20px;}
	#googleversion{margin-right: 50px;}
	#myversion{}
	#gmap_area {height:560px;}
	.gsc-resultsHeader,.gsc-above-wrapper-area,.gsc-control form,#searchresults {display:none;}
	.result {margin:8px 0px;}
	.result .result-name {font-weight:bold;color:blue;text-decoration:underline;cursor:pointer;}
</style>
</head>
<body>
	<div id="googleversion" class="localexample">
		<strong>Local Search</strong>
		<div id="searchcontrol" style="">Loading...</div>
	</div>
	<div id="myversion" class="localexample">
		<strong>Map</strong>
		<div id="gmap_area"></div>
	</div>
</body>
</html>

 

Everything works on one server, but not another.

 

Thank you in advance

Link to comment
https://forums.phpfreaks.com/topic/263993-google-places/
Share on other sites

What I'm saying to you is that you have not specified what the problem is.  Based on your post count alone, I would expect you to be familiar with asking questions round here.

 

What do you mean "isn't working" ? What do you expect? What errors? etc etc. Details chap.

Link to comment
https://forums.phpfreaks.com/topic/263993-google-places/#findComment-1353478
Share on other sites

Wow, ok, let's jump on me because I didn't "ask" the question right. I apologize for not stating the issue other than "this isn't working".

 

The problem is, no results are showing. When it is on one server, results show, and the map gets populated.

When we put it on the server that it is going to run on, no results show, and the map only shows the ocean.

 

So with that being said, can anybody see why this code does not produce any results?

 

Thanks again

Link to comment
https://forums.phpfreaks.com/topic/263993-google-places/#findComment-1353548
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.