August 29, 201412 yr I have 2 markers with the same coordinates, so i'm trying to approximate their coordinates so that they both display. I have the following code, that does not seem to work. Strange thing is that into the browser console i do not even see any error. Nothing, but no marker displays at all. for (var i = 0; i < locations.length; i++) { var item = locations[i]; var a = 0.01; var newLat = item[1] + -.00004 * Math.cos((+a*i) / 180 * Math.PI); // x var newLng = item[2] + -.00004 * Math.sin((+a*i) / 180 * Math.PI); // Y var finalLatLng = new google.maps.LatLng(newLat,newLng); var marker = new google.maps.Marker({ position: finalLatLng, map: map, title: item[0], link: item[3], address: item[5], phone: item[6], mobile: item[7], website: item[8], image: item[9], readmore: item[10], icon: item[11], type: item[12], infoWindowIndex: i }); marker.category = locations[i][12]; gmarkers.push(marker); google.maps.event.addListener(marker, 'click', function (event) { var ua = navigator.userAgent; var event = (ua.match(/iPad/i)) ? "touchstart" : "click"; // prevent ghost clicks on ipad infoBox.setContent('<div class="marker-wrapper animated fadeInDown"><div class="marker-title"> <a href="'+ this.link +'">'+ this.title +'</a> </div><div class="marker-content"><div class="two_third popup-content"><ul>'+ this.address +''+ this.phone +''+ this.mobile +''+ this.website +'</ul></div>'+ this.image +''+ this.readmore +'<div class="clearboth"></div> <div class="close" onClick=\'javascript:infoBox.close();\'><span class="icon-cancel"></span></div></div><span class="icon-down-dir"></span></div>'); infoBox.open(map, this); map.setCenter(this.position); map.panTo(this.position); }); // end click even } //end for I have also tried editing the code this way by passing a new var to the position parameter and i get the errorUncaught InvalidValueError: setPosition: not a LatLng or LatLngLiteral: not an Object Any clue how to fix this issue? Spent the whole morning trying but i haven't found a solution for (var i = 0; i < locations.length; i++) { var item = locations[i]; var myLatLng = new google.maps.LatLng(item[1], item[2] ); var marker = new google.maps.Marker({ position: myLatLng + (Math.random() -.5) / 1500, map: map, title: item[0], link: item[3], address: item[5], phone: item[6], mobile: item[7], website: item[8], image: item[9], readmore: item[10], icon: item[11], type: item[12], infoWindowIndex: i }); marker.category = locations[i][12]; gmarkers.push(marker); google.maps.event.addListener(marker, 'click', function (event) { var ua = navigator.userAgent; var event = (ua.match(/iPad/i)) ? "touchstart" : "click"; // prevent ghost clicks on ipad infoBox.setContent('<div class="marker-wrapper animated fadeInDown"><div class="marker-title"> <a href="'+ this.link +'">'+ this.title +'</a> </div><div class="marker-content"><div class="two_third popup-content"><ul>'+ this.address +''+ this.phone +''+ this.mobile +''+ this.website +'</ul></div>'+ this.image +''+ this.readmore +'<div class="clearboth"></div> <div class="close" onClick=\'javascript:infoBox.close();\'><span class="icon-cancel"></span></div></div><span class="icon-down-dir"></span></div>'); infoBox.open(map, this); map.setCenter(this.position); map.panTo(this.position); }); // end click even } //end for Any help would be appreciated. Thank you.
August 30, 201412 yr Why are you doing calculations for the latlang values? Just get the coordinates from Google Maps, they can be found by right clicking on the map and then hit 'whats here' and the coordinates appear in the info window. Hope that helps.
Create an account or sign in to comment