Total Complexity | 9 |
Complexity/F | 2.25 |
Lines of Code | 47 |
Function Count | 4 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | |||
2 | $(document).ready(function () { |
||
3 | |||
4 | function setMapByCoords(lng, lat) { |
||
5 | var myLatLng = new google.maps.LatLng(lat, lng); |
||
|
|||
6 | if (typeof google === 'undefined') { |
||
7 | return; |
||
8 | } |
||
9 | var map = new google.maps.Map(document.getElementById('map'), |
||
10 | { |
||
11 | zoom: 17, |
||
12 | center: myLatLng, |
||
13 | mapTypeId: google.maps.MapTypeId.ROADMAP |
||
14 | }); |
||
15 | var marker = new google.maps.Marker( |
||
16 | { |
||
17 | position: myLatLng, |
||
18 | map: map |
||
19 | }); |
||
20 | } |
||
21 | |||
22 | function initMap() { |
||
23 | var map_element = $('#map'); |
||
24 | var e_slug = map_element.data('event'); |
||
25 | var lng = map_element.data('lng'); |
||
26 | var lat = map_element.data('lat'); |
||
27 | if (!lng || !lat) { |
||
28 | $.ajax({ |
||
29 | type: 'post', |
||
30 | url: Routing.generate('get_event_map_position', {slug: e_slug}) |
||
31 | }).done( |
||
32 | function (data) { |
||
33 | if (data.result) { |
||
34 | setMapByCoords(data.lng, data.lat) |
||
35 | } else { |
||
36 | console.log('Error:' + data.error); |
||
37 | } |
||
38 | } |
||
39 | ); |
||
40 | } else { |
||
41 | setMapByCoords(lng, lat) |
||
42 | } |
||
43 | } |
||
44 | |||
45 | if ($('#map').length > 0) { |
||
46 | initMap(); |
||
47 | } |
||
48 | }); |
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.