Store Locator Widget - Baidu
Sample code for Woosmap Map JavaScript API
author(s):
Woosmap
HTML
<!DOCTYPE html>
<html>
<head>
<title>Store Locator Widget - Baidu</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta charset="utf-8" />
<script src="https://webapp.woosmap.com/webapp.js"></script>
<!-- jsFiddle will insert css and js -->
</head>
<body>
<div id="map"></div>
</body>
</html>
CSS
/*
* Always set the map height explicitly to define the size of the div element
* that contains the map.
*/
#map {
height: 100%;
}
/*
* Optional: Makes the sample page fill the window.
*/
html,
body {
height: 100%;
margin: 0;
padding: 0;
font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;
}
JavaScript
const storeLocatorConfig = {
theme: {
primary_color: "#00754a",
},
maps: {
provider: "baidu",
apiKey: "oUQDfIp2b7qNxIuSaghaeip7",
},
woosmapView: {
baiduMapStyle: {
style: "light",
// style: "dark"
// style: "grassgreen"
// style: 'midnight',
// style: 'pink',
// style: 'bluish',
// style: "hardedge"
},
initialCenter: {
lat: 31.230780461545375,
lng: 121.36283503342771,
},
initialZoom: 13,
breakPoint: 14,
tileStyle: {
color: "#00754a",
size: 13,
minSize: 6,
},
style: {
default: {
icon: {
url: "https://images.woosmap.com/starbucks-marker.svg",
scaledSize: {
height: 40,
width: 34,
},
},
selectedIcon: {
url: "https://images.woosmap.com/starbucks-marker-selected.svg",
scaledSize: {
height: 50,
width: 43,
},
},
},
},
},
};
function isMobileDevice() {
return window.innerWidth < 500;
}
function initStoreLocator() {
const webapp = new window.WebApp("map", "YOUR_API_KEY");
webapp.setConf(storeLocatorConfig);
webapp.render(isMobileDevice());
}
initStoreLocator();