• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 269
  • Last Modified:

How to Check Google Maps API Return Status?

Where would I check the return status from Google in this code?

	<script type="text/javascript">

		//google.maps.event.addDomListener(window, 'load', initialize);

		if(navigator.geolocation)
		{
			navigator.geolocation.getCurrentPosition(initialize);
		}
		else
		{
			alert("Your current location cannot be determined.");
		}

		function initialize(position)
		{
			var lat = '32.516053'; //position.coords.latitude
			var lon = '-93.744957'; //position.coords.longitude
			var myLatlng = new google.maps.LatLng(lat, lon);

			var mapOptions = {zoom: 14, center: myLatlng, mapTypeId: google.maps.MapTypeId.ROADMAP}
			
			alert(position.coords.latitude);
			var map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);

			var image = '/Images/marker.png';
			var memberImage = '/Images/membermarker.png';

			var locations = <%=locations%>

			var infowindow = new google.maps.InfoWindow();
			var marker, i;

			marker = new google.maps.Marker({
					position: myLatlng,
					map: map,
					icon: memberImage
				});

			google.maps.event.addListener(marker, 'click', function() {
				infowindow.setContent("My Current Location");
				infowindow.open(map, marker);
			});

			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,
					icon: image
				});

				google.maps.event.addListener(marker, 'click', (function (marker, i)
				{
					return function ()
					{
						infowindow.setContent(locations[i][0]);
						infowindow.open(map, marker);
					}
				})(marker, i));
			}
		}

Open in new window

0
Rob Gaudet
Asked:
Rob Gaudet
  • 2
1 Solution
 
Rob GaudetAuthor Commented:
I'm having a problem getting the Google maps api to load, below are the locations. I'm not sure exactly how to debug what the problem is??


var locations = [
['<div style="text-align:left; padding:10px;"><h3>Starbucks Coffee</h3><b>asdf</b><br><img style="width:150px; margin-top:10px;" src="http://localhost:51081/ProductImages/thumbx215_f485efbe-711a-478f-bd91-e580a9cf0d49.png"></div>', 32.4541899, -93.747131, 1],
['<div style="text-align:left; padding:10px;"><h3>Starbucks Coffee</h3><b>Test</b><br><img style="width:150px; margin-top:10px;" src="http://localhost:51081/ProductImages/thumbx215_5549bbe9-7e02-47bf-ad11-d78bf478dc2f.gif"></div>', 32.4541899, -93.747131, 2],
['<div style="text-align:left; padding:10px;"><h3>NA</h3><b>adf</b><br><img style="width:150px; margin-top:10px;" src="http://localhost:51081/ProductImages/thumbx215_5771deb8-b80a-4eff-9cb7-1051c43cef00.jpg"></div>', 32.588626, -93.697975, 3],
['<div style="text-align:left; padding:10px;"><h3>NA</h3><b>adsf</b><br><img style="width:150px; margin-top:10px;" src="http://localhost:51081/ProductImages/thumbx215_7062d97b-47b7-46f0-9665-ac0e391dfd6c.jpg"></div>', 32.588626, -93.697975, 4],
['<div style="text-align:left; padding:10px;"><h3>NA</h3><b>Chamber Image</b><br><img style="width:150px; margin-top:10px;" src="http://localhost:51081/ProductImages/thumbx215_65ffeab1-dcdb-4292-9df0-d2f2e83b8195.jpg"></div>', 32.588626, -93.697975, 5],
['<div style="text-align:left; padding:10px;"><h3>NA</h3><b>df</b><br><img style="width:150px; margin-top:10px;" src="http://localhost:51081/ProductImages/thumbx215_6bc52518-b208-459c-aa42-776348c2a8bc.jpg"></div>', 32.588626, -93.697975, 6],
['<div style="text-align:left; padding:10px;"><h3>Newks</h3><b>Bowling Pin</b><br><img style="width:150px; margin-top:10px;" src="http://localhost:51081/ProductImages/thumbx215_fc0173f3-595f-4965-8d1e-053c65f1ecdf.jpg"></div>', 32.588661, -93.6980449, 7],
['<div style="text-align:left; padding:10px;"><h3>Newks</h3><b>Flannel Shirt</b><br><img style="width:150px; margin-top:10px;" src="http://localhost:51081/ProductImages/thumbx215_c6cde51b-1dc0-4420-b9fd-7bcdef9f5039.jpg"></div>', 32.588661, -93.6980449, 8],
['<div style="text-align:left; padding:10px;"><h3>Newks</h3><b>News Sandwhich</b><br><img style="width:150px; margin-top:10px;" src="http://localhost:51081/ProductImages/thumbx215_3c080975-8d2b-433b-a946-588016a908ec.jpg"></div>', 32.588661, -93.6980449, 9],
['<div style="text-align:left; padding:10px;"><h3>Newks</h3><b>Patrick Holding Sign Photograp</b><br><img style="width:150px; margin-top:10px;" src="http://localhost:51081/ProductImages/thumbx215_651bfc5d-0019-4d73-a1fc-3d9ade72a705.jpg"></div>', 32.588661, -93.6980449, 10],
['<div style="text-align:left; padding:10px;"><h3>Newks</h3><b>tie</b><br><img style="width:150px; margin-top:10px;" src="http://localhost:51081/ProductImages/thumbx215_5436faf5-85e8-4549-bd5f-6edad1dd8cd2.jpg"></div>', 32.588661, -93.6980449, 11]

];

Open in new window

0
 
leakim971PluritechnicianCommented:
I start from scratch from here : https://developers.google.com/maps/documentation/javascript/examples/marker-animations-iteration

with your locations : http://jsfiddle.net/w4q5T/


var locations = [
['<div style="text-align:left; padding:10px;"><h3>Starbucks Coffee</h3><b>asdf</b><br><img style="width:150px; margin-top:10px;" src="http://localhost:51081/ProductImages/thumbx215_f485efbe-711a-478f-bd91-e580a9cf0d49.png"></div>', 32.4541899, -93.747131, 1],
['<div style="text-align:left; padding:10px;"><h3>Starbucks Coffee</h3><b>Test</b><br><img style="width:150px; margin-top:10px;" src="http://localhost:51081/ProductImages/thumbx215_5549bbe9-7e02-47bf-ad11-d78bf478dc2f.gif"></div>', 32.4541899, -93.747131, 2],
['<div style="text-align:left; padding:10px;"><h3>NA</h3><b>adf</b><br><img style="width:150px; margin-top:10px;" src="http://localhost:51081/ProductImages/thumbx215_5771deb8-b80a-4eff-9cb7-1051c43cef00.jpg"></div>', 32.588626, -93.697975, 3],
['<div style="text-align:left; padding:10px;"><h3>NA</h3><b>adsf</b><br><img style="width:150px; margin-top:10px;" src="http://localhost:51081/ProductImages/thumbx215_7062d97b-47b7-46f0-9665-ac0e391dfd6c.jpg"></div>', 32.588626, -93.697975, 4],
['<div style="text-align:left; padding:10px;"><h3>NA</h3><b>Chamber Image</b><br><img style="width:150px; margin-top:10px;" src="http://localhost:51081/ProductImages/thumbx215_65ffeab1-dcdb-4292-9df0-d2f2e83b8195.jpg"></div>', 32.588626, -93.697975, 5],
['<div style="text-align:left; padding:10px;"><h3>NA</h3><b>df</b><br><img style="width:150px; margin-top:10px;" src="http://localhost:51081/ProductImages/thumbx215_6bc52518-b208-459c-aa42-776348c2a8bc.jpg"></div>', 32.588626, -93.697975, 6],
['<div style="text-align:left; padding:10px;"><h3>Newks</h3><b>Bowling Pin</b><br><img style="width:150px; margin-top:10px;" src="http://localhost:51081/ProductImages/thumbx215_fc0173f3-595f-4965-8d1e-053c65f1ecdf.jpg"></div>', 32.588661, -93.6980449, 7],
['<div style="text-align:left; padding:10px;"><h3>Newks</h3><b>Flannel Shirt</b><br><img style="width:150px; margin-top:10px;" src="http://localhost:51081/ProductImages/thumbx215_c6cde51b-1dc0-4420-b9fd-7bcdef9f5039.jpg"></div>', 32.588661, -93.6980449, 8],
['<div style="text-align:left; padding:10px;"><h3>Newks</h3><b>News Sandwhich</b><br><img style="width:150px; margin-top:10px;" src="http://localhost:51081/ProductImages/thumbx215_3c080975-8d2b-433b-a946-588016a908ec.jpg"></div>', 32.588661, -93.6980449, 9],
['<div style="text-align:left; padding:10px;"><h3>Newks</h3><b>Patrick Holding Sign Photograp</b><br><img style="width:150px; margin-top:10px;" src="http://localhost:51081/ProductImages/thumbx215_651bfc5d-0019-4d73-a1fc-3d9ade72a705.jpg"></div>', 32.588661, -93.6980449, 10],
['<div style="text-align:left; padding:10px;"><h3>Newks</h3><b>tie</b><br><img style="width:150px; margin-top:10px;" src="http://localhost:51081/ProductImages/thumbx215_5436faf5-85e8-4549-bd5f-6edad1dd8cd2.jpg"></div>', 32.588661, -93.6980449, 11]

];    
    
var berlin = new google.maps.LatLng(32.588661, -93.6980449);

var markers = [];
var iterator = 0;

var map;

function initialize() {
  var mapOptions = {
    zoom: 5,
    mapTypeId: google.maps.MapTypeId.ROADMAP,
    center: berlin
  };

  map = new google.maps.Map(document.getElementById('map_canvas'),  mapOptions);
    for (var i = 0; i < locations.length; i++) {
    setTimeout(function() {
      addMarker();
    }, i * 1000);
  }

}

function addMarker() {
  markers.push(new google.maps.Marker({
    position: new google.maps.LatLng(locations[iterator][1],locations[iterator][2]),
    map: map,
    draggable: false,
    animation: google.maps.Animation.DROP
  }));
  iterator++;
}

google.maps.event.addDomListener(window, 'load', initialize);

Open in new window

0
 
Rob GaudetAuthor Commented:
Thanks leak, that helped.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now