Solved

How to Check Google Maps API Return Status?

Posted on 2013-11-06
3
243 Views
Last Modified: 2013-11-12
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
Comment
Question by:Rob Gaudet
  • 2
3 Comments
 

Author Comment

by:Rob Gaudet
ID: 39627804
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
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 39628158
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
 

Author Comment

by:Rob Gaudet
ID: 39642074
Thanks leak, that helped.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (http://www.experts-exchange.com/A_3488.html), typical array handling might look like this: (CODE) B…
I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now