Skip to content

Commit cc6a3cd

Browse files
Update jQuery
1 parent 3f66c73 commit cc6a3cd

File tree

10 files changed

+44
-917
lines changed

10 files changed

+44
-917
lines changed

Readme.md renamed to README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,9 @@ The Map component allows obtaining the instance in the <a href="https://js.dev
1515

1616
## Files to Review
1717

18-
## Files to Review
19-
2018
- **jQuery**
2119
- [index.html](jQuery/src/index.html)
2220
- [index.js](jQuery/src/index.js)
23-
- [index.css](jQuery/src/index.css)
24-
- [markerWithLabel.js](jQuery/src/markerWithLabel.js)
2521

2622
## Documentation
2723

config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"runOnWeb": true,
2+
"runOnWeb": false,
33
"autoGenerateVb": false
44
}
File renamed without changes.

jQuery/.eslintignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
node_modules/*
2-
src/markerWithLabel.js

jQuery/src/index.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@
1010
<link rel="stylesheet" type="text/css" href="index.css" />
1111
<script type="text/javascript" src="../node_modules/jquery/dist/jquery.js"></script>
1212
<script type="text/javascript" src="../node_modules/devextreme-dist/js/dx.all.js"></script>
13-
<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY"></script>
14-
<script type="text/javascript" src="markerWithLabel.js"></script>
1513
<script type="text/javascript" src="index.js"></script>
14+
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBIw1-l1otL9v1bY-OR4p9w21l1VLu9L2k&loading=async&libraries=marker&callback=initMap" async defer></script>
1615
</head>
1716

1817
<body class="dx-viewport">

jQuery/src/index.js

Lines changed: 42 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,52 @@
1-
$(() => {
2-
$('#map').dxMap({
3-
apiKey: 'YOUR_API_KEY',
1+
function initMap() {
2+
const map = $('#map').dxMap({
3+
center: '49.47805, -123.84716',
4+
zoom: 14,
45
width: 1200,
56
height: 620,
6-
zoom: 14,
7-
center: '49.47805, -123.84716',
87
provider: 'google',
8+
apiKey: {
9+
google: 'YOUR_API_KEY',
10+
},
11+
providerConfig: {
12+
mapId: 'DEMO_MAP_ID',
13+
},
914
onReady(s) {
10-
const map = s.originalMap;
11-
const homeLatLng = new google.maps.LatLng(49.47805, -123.84716);
15+
const googleMap = s.originalMap;
16+
17+
const createMarkerContent = (price, opacity = 1) => {
18+
const content = document.createElement('div');
19+
content.className = 'labels';
20+
content.textContent = price;
21+
content.style.opacity = opacity;
22+
return content;
23+
};
1224

13-
const marker1 = new MarkerWithLabel({
14-
position: homeLatLng,
15-
draggable: false,
16-
clickable: false,
17-
map,
18-
labelContent: '$425K',
19-
labelAnchor: new google.maps.Point(-21, 3),
20-
labelClass: 'labels', // the CSS class for the label
21-
labelStyle: { opacity: 0.75 },
25+
const marker1 = new google.maps.marker.AdvancedMarkerElement({
26+
map: googleMap,
27+
position: { lat: 49.47805, lng: -123.84716 },
28+
content: createMarkerContent('$425K', 0.75),
29+
// eslint-disable-next-line spellcheck/spell-checker
30+
gmpDraggable: false,
31+
// eslint-disable-next-line spellcheck/spell-checker
32+
gmpClickable: false,
2233
});
2334

24-
const marker2 = new MarkerWithLabel({
25-
position: new google.maps.LatLng(49.475, -123.84),
26-
draggable: true,
27-
map,
28-
labelContent: '$395K',
29-
labelAnchor: new google.maps.Point(-21, 3),
30-
labelClass: 'labels', // the CSS class for the label
31-
labelStyle: { opacity: 1.0 },
35+
const marker2 = new google.maps.marker.AdvancedMarkerElement({
36+
map: googleMap,
37+
position: { lat: 49.475, lng: -123.84 },
38+
content: createMarkerContent('$395K', 1.0),
39+
// eslint-disable-next-line spellcheck/spell-checker
40+
gmpDraggable: true,
3241
});
3342
},
34-
});
43+
}).dxMap('instance');
44+
}
45+
46+
window.initMap = initMap;
47+
48+
$(() => {
49+
if (window.google && window.google.maps) {
50+
initMap();
51+
}
3552
});

0 commit comments

Comments
 (0)