JSFiddle - React, Tailwind, and code Playground
by Benderlio
HTML
<!DOCTYPE html>
<html>
<head>
<title>Place Autocomplete</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<script src="https://maps.googleapis.com/maps/api/js?v=3"></script>
<script src="https://code.jquery.com/jquery-1.12.4.min.js" integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ=" crossorigin="anonymous"></script>
<style>
#map {
height: 100%;
}
/* Optional: Makes the sample page fill the window. */
html,
body {
height: 100%;
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<button id="dis" class="buttons" style="background-color: #fff">Dis</button>
<button id="en" class="buttons" style="background-color: #fff">En</button>
<div id="map"></div>
<script>
var map;
function initMap() {
directionsService = new google.maps.DirectionsService();
directionsDisplay = new google.maps.DirectionsRenderer();
map = new google.maps.Map(document.getElementById('map'), {
center: {
lat: 42.418664992,
lng: -71.104832914
},
zoom: 13,
});
//creating the class to exntend the google map OverlayView class
function MapLocationIcon(id,lat,lng,title,icon_class){
this.lat = lat;
this.lng = lng;
this.title = title; //eg. A,B,C.D
this.icon_class= icon_class; //the position of the spritesheet for the icon background
this.pos = new google.maps.LatLng(lat,lng);
}
//make a copy of the OverlayView to extend it
MapLocationIcon.prototype = new google.maps.OverlayView();
MapLocationIcon.prototype.onRemove= function(){}
//prepare the overlay with DOM
MapLocationIcon.prototype.onAdd= function(){
div = document.createElement('DIV');
...