SearchLocation - Woosmap Javascript API Search Location Demo
jsFiddle demo that allow the use of Google maps basic geocoding using Woosmap Javascript API. author(s): Woosmap DevTeam
by woosmap
HTML
<script src="https://sdk.woosmap.com/locator/loader.js"></script>
<script id="search_template" type="text/mustache">
<div>
<input class="search_input" placeholder="Search an Address..."/>
<span class="search_clear"></span>
</div>
</script>
<div class="locator-container pure-g">
<div class="sidebar pure-u-1 u-sm-1-3">
<div id="listings" class="listings"></div>
</div>
<div id="my-map" class="map pure-u-1 u-sm-2-3"></div>
</div>
CSS
#my-map {
height: 500px;
}
.locator-container {
font-size: 15px;
line-height: 1.5em;
color: #555;
background: #FFF;
}
.sidebar {
height: 500px;
overflow: hidden;
border: 1px solid #EEE;
border-right: none;
}
.listings {
height: 460px;
padding-bottom: 36px;
background-color: #FFF;
color: #555;
}
.woosmap-tableview-container, .card_container {
max-height: 100%;
overflow-y: scroll;
overflow-x: hidden;
}
.item {
display: block;
border-bottom: 1px solid #eee;
padding: 10px;
text-decoration: none;
cursor: pointer;
}
.item .title {
display: block;
color: #03A9F4;
font-weight: 500;
}
.item .title small {
font-weight: 300;
}
.quiet {
color: #888;
}
small {
font-size: 80%;
}
.selected_card .item .title,
.item .title:hover {
color: #0288D1;
}
.item.active {
background-color: #f8f8f8;
}
.selected_card {
background-color: #f8f8f8;
}
.selected_card:hover {
background-color: #f8f8f8;
}
.search_container {
margin: 5px;
border: 1px solid #03A9F4;
border-radius: 2px;
box-sizing: border-box;
-moz-box-sizing: border-box;
height: 32px;
outline: none;
padding: 0 7px;
width: 96%;
vertical-align: top;
position: relative;
}
.search_input {
border: none;
padding: 0;
height: 1.25em;
width: 100%;
z-index: 6;
outline: none;
background: #FFF;
margin-top: 7px;
float: left;
font-size: 1em;
color: #555;
}
.search_clear {
float: right;
background: white url('https://images.woosmap.com/close.png') no-repeat left top;
position: absolute;
right: 5px;
top: 8px;
padding: 7px;
font-size: 14px;
cursor: pointer;
display: none;
}
.search_clear:hover {
background: white url('https://images.woosmap.com/close-hover.png') no-repeat left top;
}
.woosmap-tableview-highlighted-cell {
background-color: #f8f8f8;
}
::-webkit-scrollbar {
...
JavaScript
var projectKey = '12345678';
var googleClientId = 'gme-webgeoservicessa';
var initializedMapview = false;
var map, tableview;
var markersStyle = {
rules: [{
type: 'drive',
icon: {
url: 'https://images.woosmap.com/marker_drive.svg',
scaledSize: {
width: 36,
height: 48
}
},
selectedIcon: {
url: 'https://images.woosmap.com/marker_drive_selected.svg',
scaledSize: {
width: 46,
height: 60
}
},
numberedIcon: {
url: 'https://images.woosmap.com/marker_drive_selected.svg',
scaledSize: {
width: 46,
height: 60
}
}
}],
default: {
icon: {
url: 'https://images.woosmap.com/marker_default.svg',
scaledSize: {
width: 36,
height: 48
}
},
selectedIcon: {
url: 'https://images.woosmap.com/marker_selected.svg',
scaledSize: {
width: 46,
height: 60
}
}
}
};
var tilesStyle = {
color: '#0288D1',
size: 11,
minSize: 6,
typeRules: [{
type: 'drive',
color: '#FF5722'
}]
};
function registerDraggableMarker(mapView) {
mapView.marker.setOptions({
draggable: true,
icon: {
url: 'https://images.woosmap.com/geolocated.png'
}
});
}
function initMapView() {
var mapView = new woosmap.TiledView(map, {
style: markersStyle,
tileStyle: tilesStyle
});
mapView.bindTo('stores', tableview, 'stores', false);
mapView.bindTo('selectedStore', tableview, 'selectedStore', false);
mapView.bindTo('location', geocoder);
mapView.delegate = {
'didLocationMarkerDragEnd': function() {
searchview.$searchInput.val('');
}
};
registerDraggableMarker(mapView);
searchview.delegate = {
didClearSearch: function() {
tableview.set('stores', defaultStores);
mapView.set('selectedStore', null);
mapView.set('location', {})
}
};
initializedMapview = true;
}
/*----- Init and display a Map with a...