Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="container">

	<div id="mapContainer"></div>

	<div>
		<input type="search" id="searchBox"> 
		<button id="searchBtn">Search</button>
	</div>

</div>

              
            
!

CSS

              
                			.container {
				display: grid;
				grid-template-columns: 50% 50%;
			}

			#mapContainer {
				width: 600px;
				height: 600px;
			}

              
            
!

JS

              
                const KEY = 'c1LJuR0Bl2y02PefaQ2d8PvPnBKEN8KdhAOFYR_Bgmw';
var platform = new H.service.Platform({
	'apikey': KEY
});

// Obtain the default map types from the platform object:
var defaultLayers = platform.createDefaultLayers();

var map = new H.Map(
	document.getElementById('mapContainer'),
	defaultLayers.vector.normal.map,
	{
		zoom: 14,
		center: { lat: 30.22, lng: -92.02 },
		pixelRatio: window.devicePixelRatio || 1
	}
);
		
var behavior = new H.mapevents.Behavior(new H.mapevents.MapEvents(map));
var ui = H.ui.UI.createDefault(map, defaultLayers);
		
let bubble;
var group = new H.map.Group();
map.addObject(group);
group.addEventListener('tap', evt => {

	let position = map.screenToGeo(evt.currentPointer.viewportX, evt.currentPointer.viewportY),
			data = evt.target.getData();

	if (!bubble) {
		bubble = new H.ui.InfoBubble(position, { content: '' })
		ui.addBubble(bubble);
	}

	bubble.setContent(`
<div style="height:130px; overflow:auto;width: 270px;">
<h3>${data.title}</h3>
<p>
${data.address.label}
</p>
</div>`);

	bubble.setPosition(position);
	bubble.open();

	map.setCenter(position, true);	

}, false);

const apiKey = 'c1LJuR0Bl2y02PefaQ2d8PvPnBKEN8KdhAOFYR_Bgmw';

document.addEventListener("DOMContentLoaded", function(){
	let box = document.querySelector('#searchBox');
	let btn = document.querySelector('#searchBtn');

	let searchMarkers = [];
	btn.addEventListener('click', async () => {
		if(box.value === '') return;

		//clear and reset old ones
		if(searchMarkers.length) {
			while(searchMarkers.length) {
				group.removeObject(searchMarkers.shift());
			}
		}
		if(bubble) bubble.close();

		let resp = await fetch(`https://browse.search.hereapi.com/v1/browse?apikey=${apiKey}&name=${encodeURIComponent(box.value)}&at=30.22,-92.02&categories=203-026&limit=10`);

		let data = await resp.json();
		for (var i = 0; i < data.items.length; i++) {
			var coords = data.items[i].position;
			let marker = new H.map.Marker({lat:coords.lat, lng:coords.lng});
			marker.setData(data.items[i]);
			searchMarkers.push(marker);
			group.addObject(marker);
		}

	}, false);

},false);

              
            
!
999px

Console