Release SDK 1.3 - MouseHover Event
jsFiddle demo that allow Mouse Over Event, whartever the view (Tiled or Marker) author(s): Woosmap DevTeam
by woosmap
HTML
<script src="https://sdk.woosmap.com/locator/loader.js"></script>
<div id="my-map"></div>
<div class="info-container">
<div id="mouse-hover-content"><strong>Information:</strong>
<br/> Click or Hover a marker on the map to display infocontent in this box
</div>
</div>
<div class="event-container">event: <strong id="mouse-event-value"></strong></div>
CSS
#my-map {
height: 500px;
width: 100%;
}
#mouse-hover-content,
.event-container {
padding: 8px;
border-style: none;
border-radius: 2px;
box-shadow: rgba(0, 0, 0, 0.298039) 0 1px 4px -1px;
background-color: rgb(255, 255, 255);
max-height: 450px;
overflow: auto;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
}
.info-container {
margin: 18px;
z-index: 0;
position: absolute;
display: block;
max-width: 280px;
max-height: 450px;
left: 0;
top: 0;
}
.event-container {
margin: 18px;
z-index: 0;
position: absolute;
display: block;
right: 0;
top: 0;
}
/******** Infowindow Style **********/
#mouse-hover-content > div {
line-height: 1.5em;
}
#mouse-hover-content a {
color: #2196f3;
}
.store-photo {
margin: -8px;
}
.store-photo img {
object-fit: cover;
width: 100%;
overflow: hidden;
}
.store-title {
color: #FFF;
background-color: #03A9F4;
padding: 10px 8px;
margin: -8px;
margin-bottom: 8px;
font-size: 1.1em;
}
.store-opened {
font-weight: bold;
line-height: 1.5em;
}
JavaScript
var projectKey = 'foodmarkets-woos';
var markersStyle = {
"default": {
"icon": {
"url": "https://s3.eu-central-1.amazonaws.com/webapp-conf.woosmap.com/foodmarkets-woos/default.svg",
"anchor": {
"x": 16,
"y": 16
}
},
"selectedIcon": {
"url": "https://s3.eu-central-1.amazonaws.com/webapp-conf.woosmap.com/foodmarkets-woos/selected.svg",
"anchor": {
"x": 21,
"y": 21
}
}
}
};
var tilesStyle = {
"color": "#e31a1c",
"size": 10,
"minSize": 5
};
var customTemplate = "<div class='store-photo' ><img src='{{user_properties.photo}}'/></div><div class='store-title'>{{name}}</div><div class='store-opened'>{{openlabel}}</div><div class='store-address'>{{address.lines}} {{address.city}} {{address.zip}}</div><div class='store-website'><a href='{{contact.website}}' target='_blank'>{{hostname}}</a></div>{{#contact.phone}}<div class='store-contact'>Tel : <a href='tel:{{contact.phone}}'>{{contact.phone}}</a></div>{{/contact.phone}}";
/*----- Template Renderer -----*/
function getRenderedTemplate(store) {
var templateRenderer = new woosmap.TemplateRenderer(customTemplate)
var url = store.properties.contact.website;
var hostname = (new URL(url)).hostname;
store.properties.hostname = hostname.replace("www.", "");
store.properties.openlabel = (store.properties.open.open_now) ? "Open Now" : "Close";
return templateRenderer.render(store.properties);
}
/*----- Handle Mouse Events -----*/
function registerMouseHoverEvent(mapView) {
mapView.addListener('mouseover', function(store) {
woosmap.$('#mouse-hover-content').html(getRenderedTemplate(store));
woosmap.$('#mouse-event-value').text('mouseover');
});
}
function registerAllMouseEvent(mapView) {
mapView.addListener('click', function(store) {
woosmap.$('#mouse-event-value').text('click');
});
mapView.addListener('mouseup', function(store) {
woosmap.$('#mouse-event-value').text('mouseup');
});
...