Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught SyntaxError: Unexpected token , in Google map when lat / long is null #44

Closed
bobbingwide opened this issue Jul 14, 2016 · 3 comments
Assignees

Comments

@bobbingwide
Copy link
Owner

Detected on anchorgolf.com the generated JavaScript produces the Uncaught SyntaxError in the following line generated to display a Google Map.

var latlng = new google.maps.LatLng(,);

Workaround

Enter values for the lat and long.

@bobbingwide
Copy link
Owner Author

bobbingwide commented May 27, 2017

The problem is associated with the "googlemap" virtual field in oik-fields.
Function bw_fields_get_google_map() in includes\oik-fields-virtual-google-map.php
which calls bw_googlemap_v3() directly.

$google_map = bw_googlemap_v3( get_the_title( $ID )   
 , $lat
 , $long
 , $post_code
 , "100%"
 , "400px"
 );

The simple solution would be to not call the function if either $lat or $long was null.

@bobbingwide
Copy link
Owner Author

It's possible to produce the same problem by setting lat and long to blanks.
It's also possible to create a different error by setting the fields to non-numeric values.
e.g.

Uncaught ReferenceError: x is not defined
    at initialize0 

So, it would make sense to perform some validation of the lat and long values when setting the combined $latlng field.

@bobbingwide
Copy link
Owner Author

bobbingwide commented May 28, 2017

Having changed the logic to use a function called bw_gmap_latlng() I've subsequently discovered that the bw_gmap_markers() function doesn't handle markers where the latitude and longitude are defined using the lat:lng method and the value of lat is an integer.
This test will pass for $marker set to "30:30"

      if ( $marker == absint( $marker ) ) {

Also note that the maximum latitude supportey by GoogleMaps is 85 degrees.
See https://stackoverflow.com/questions/11849636/maximum-lat-and-long-bounds-for-the-world-google-maps-api-latlngbounds

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant