Solved

How to Check Google Maps API Return Status?

Posted on 2013-11-06
3
252 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
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…

688 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