Jump to content

Function Not Defined


Tenaciousmug

Recommended Posts

Okay I know this error is common. And it's mainly always a syntax problem, but I can not for the life of me figure out what is wrong with my code. I tried putting the getUrlParameter function inside the document.ready() function.. I also tried both of them outside of it.. every possibility you can imagine, I tried. So it has to be something else. I've been staring at it for the past hour or so...

Maybe a second pair of eyes can help me out here.

 

<script type="text/javascript">
function getURLParameter(name) {
 /*var parameter = decodeURI(
	 (RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1]
 );

 if (parameter == null) {
  return null;
 } else {
  return parameter;
 }*/
 name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
   var regexS = "[\\?&]"+name+"=([^]*)";
   var regex = new RegExp( regexS );
   var results = regex.exec( window.location.href );
   if( results == null ) {
  return null;
   } else {
  return results[1];
   }
}
$(document).ready(function() {
var lng = getUrlParameter('long');
var lat = getUrlParameter('lat');
if(lng==null && lat==null) {
 var mapOptions = {
  zoom: 8,
  center: new google.maps.LatLng(-34.397, 150.644),
  mapTypeId: google.maps.MapTypeId.ROADMAP
 };
} else {
 var mapOptions = {
  zoom: 8,
  center: new google.maps.LatLng(lat, lng),
  mapTypeId: google.maps.MapTypeId.ROADMAP
 };
}
var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
});
</script>

 

Thank you!

Link to comment
https://forums.phpfreaks.com/topic/269646-function-not-defined/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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