diff --git a/sdks-and-frameworks/web/tutorial/1-set-up-your-environment.md b/sdks-and-frameworks/web/tutorial/1-set-up-your-environment.md
new file mode 100644
index 00000000..c5013f58
--- /dev/null
+++ b/sdks-and-frameworks/web/tutorial/1-set-up-your-environment.md
@@ -0,0 +1,34 @@
+---
+description: Step 1. Set Up Your Environment
+---
+
+# Step 1. Set Up Your Environment
+
+1. If you do not have prior development experience, you can install an Integrated Development Environment (IDE), e.g. [Visual Studio Code](https://code.visualstudio.com/).
+2. Start by creating a new project folder. The location is not important, just remember the location, and ensure your newly created project folder is empty.
+3. Inside that, create two empty files: `index.html` and `script.js`.
+
+ > The file `index.html` is the entry point for our application and contains the HTML code. The file `script.js` will be read by `index.html` and consists of the JavaScript code for the actual application to run. To try the app you will be creating, run `index.html` in your web browser.
+4. Open `index.html`. Create a basic HTML structure and include the `script.js` file as follows:
+
+```html
+
+
+
+
+
+
+
+ MapsIndoors
+
+
+
+
+
+
+
+```
+
+Both here, and in the following examples, you will always be able to see which of the two files the code should go in, by looking at the first line, where the name of the file is written.
+
+Your environment is now fully configured, and you have the necessary API keys. Next, you will learn how to display a map with MapsIndoors.
diff --git a/sdks-and-frameworks/web/tutorial/tutorial.md b/sdks-and-frameworks/web/tutorial/tutorial.md
index b00d3e4f..72f7b61e 100644
--- a/sdks-and-frameworks/web/tutorial/tutorial.md
+++ b/sdks-and-frameworks/web/tutorial/tutorial.md
@@ -6,32 +6,31 @@ Throughout the Getting Started guide, you will modify and extend the same code t
1. If you do not have prior development experience, you can install an Integrated Development Environment (IDE), e.g. [Visual Studio Code](https://code.visualstudio.com/).
2. Start by creating a new project folder. The location is not important, just remember the location, and ensure your newly created project folder is empty.
-3. Inside that, create two empty files: `index.html` and `main.js`.
+3. Inside that, create two empty files: `index.html` and `script.js`.
- > The file `index.html` is the entry point for our application and contains the HTML code. The file `main.js` will be read by `index.html` and consists of the JavaScript code for the actual application to run. To try the app you will be creating, run `index.html` in your web browser.
-4. Open `index.html`. Create a basic HTML structure and include the `main.js` file as follows:
+ > The file `index.html` is the entry point for our application and contains the HTML code. The file `script.js` will be read by `index.html` and consists of the JavaScript code for the actual application to run. To try the app you will be creating, run `index.html` in your web browser.
+4. Open `index.html`. Create a basic HTML structure and include the `script.js` file as follows:
```html
-
+
-
-
-
- MapsIndoors
+
+
+ MapsIndoors
+
-
+
+
```
Both here, and in the following examples, you will always be able to see which of the two files the code should go in, by looking at the first line, where the name of the file is written.
-
-
Your environment is now fully configured, and you have the necessary API keys. Next, you will learn how to display a map with MapsIndoors.
## Step 2. Display a Map with MapsIndoors[](https://docs.mapsindoors.com/getting-started/web/map#show-a-map-with-mapsindoors)
@@ -44,58 +43,64 @@ Insert the MapsIndoors SDK script tag into ``, followed by the Google Maps
```html
-
+
-
MapsIndoors
-
-
+
+
+
-
+
+
```
-Remember to add your API keys to the links in your code. If you do not have your own API key, you can use the demo MapsIndoors API key: `d876ff0e60bb430b8fabb145`.
-
Add an empty `
` element to `` with the `id` attribute set to `"map"`:
```html
-
+
-
MapsIndoors
-
+
+
-
-
+
+
+
```
-To load data and display it on the map, we need to create a new _instance_ of the [`MapsIndoors` class](https://app.mapsindoors.com/mapsindoors/js/sdk/latest/docs/mapsindoors.MapsIndoors.html#MapsIndoors) with a [`mapView` instance](https://app.mapsindoors.com/mapsindoors/js/sdk/latest/docs/mapsindoors.mapView.GoogleMapsView.html#GoogleMapsView) with a few _properties_ set. This is all done by placing the following code in the `main.js` file you created earlier:
+To load data and display it on the map, we need to create a new _instance_ of the [`MapsIndoors` class](https://app.mapsindoors.com/mapsindoors/js/sdk/latest/docs/mapsindoors.MapsIndoors.html#MapsIndoors) with a [`mapView` instance](https://app.mapsindoors.com/mapsindoors/js/sdk/latest/docs/mapsindoors.mapView.GoogleMapsView.html#GoogleMapsView) with a few _properties_ set. This is all done by placing the following code in the `script.js` file you created earlier:
+
+In the `script.js` code below, replace `YOUR_MAPSINDOORS_API_KEY` with your actual MapsIndoors API key. For testing, you can use the demo API key: `02c329e6777d431a88480a09`.
```javascript
-// main.js
+// script.js
const mapViewOptions = {
element: document.getElementById('map'),
- center: { lat: 38.8974905, lng: -77.0362723 }, // The White House
+ center: { lat: 30.359285384, lng: -97.7412840716576 }, // MapsPeople - Austin Office
zoom: 17,
maxZoom: 22,
};
+
+//Set the MapsIndoors API key
+mapsindoors.MapsIndoors.setMapsIndoorsApiKey('YOUR_MAPSINDOORS_API_KEY');
+
const mapViewInstance = new mapsindoors.mapView.GoogleMapsView(mapViewOptions);
const mapsIndoorsInstance = new mapsindoors.MapsIndoors({
mapView: mapViewInstance
@@ -112,15 +117,21 @@ Next, we'll add a Floor Selector for changing between floors.
First, we add an empty `
` element programmatically. Then we create a new [`FloorSelector` _instance_](https://app.mapsindoors.com/mapsindoors/js/sdk/latest/docs/FloorSelector.html) and push the `floorSelectorElement` to the `googleMapsInstance` to position it as a map controller:
+In the `script.js` code below, replace `YOUR_MAPSINDOORS_API_KEY` with your actual MapsIndoors API key. For testing, you can use the demo API key: `02c329e6777d431a88480a09`.
+
```javascript
-// main.js
+// script.js
const mapViewOptions = {
element: document.getElementById('map'),
- center: { lat: 38.8974905, lng: -77.0362723 }, // The White House
+ center: { lat: 30.359285384, lng: -97.7412840716576 }, // MapsPeople - Austin Office
zoom: 17,
maxZoom: 22,
};
+
+//Set the MapsIndoors API key
+mapsindoors.MapsIndoors.setMapsIndoorsApiKey('YOUR_MAPSINDOORS_API_KEY');
+
const mapViewInstance = new mapsindoors.mapView.GoogleMapsView(mapViewOptions);
const mapsIndoorsInstance = new mapsindoors.MapsIndoors({ mapView: mapViewInstance });
const googleMapsInstance = mapViewInstance.getMap();
@@ -147,18 +158,17 @@ Insert script tag into ``:
```html
-
+
-
MapsIndoors
-
+
-
+
```
@@ -169,42 +179,40 @@ After you added the script tag into ``, add the `` cust
```html
-
+
-
MapsIndoors
-
+
-
+
```
-Remember to add your API keys where indicated. You can use the demo MapsIndoors API key: `d876ff0e60bb430b8fabb145`
+Remember to add your API keys where indicated. You can use the demo MapsIndoors API key: `02c329e6777d431a88480a09`
To center the map correctly, you need need the Google Maps _instance_ in your JavaScript-file.
First, we get a reference to the `` element. Then we attach the [`mapsIndoorsReady`](https://app.mapsindoors.com/mapsindoors/js/sdk/latest/docs/mapsindoors.MapsIndoors.html#event:ready) event listener so we'll know when MapsIndoors is ready after loading. Lastly, on the `mapsIndoorsReady` event, get the Google Maps _instance_ and call its [`setCenter` method](https://developers.google.com/maps/documentation/javascript/reference/map#Map.setCenter) to center the map on the loaded data:
```javascript
-// main.js
+// script.js
const miMapElement = document.querySelector('mi-map-googlemaps');
miMapElement.addEventListener('mapsIndoorsReady', () => {
miMapElement.getMapInstance().then((mapInstance) => {
- mapInstance.setCenter({ lat: 38.8974905, lng: -77.0362723 }); // The White House
+ mapInstance.setCenter({ lat: 30.359285384, lng: -97.7412840716576 }); // MapsPeople - Austin Office
});
})
```
@@ -221,26 +229,26 @@ Using the `` element, you can add the [floorSelectorControlPo
```html
-
+
-
MapsIndoors
-
+
+
+ style="width: 720px; height: 480px;"
+ gm-api-key="YOUR_GOOGLE_MAPS_API_KEY"
+ mi-api-key="YOUR_MAPSINDOORS_API_KEY"
+ floor-selector-control-position="TOP_RIGHT">
-
+
+
```
@@ -251,7 +259,7 @@ Here's a JSFiddle demonstrating the result you should have by now:
{% embed url="https://jsfiddle.net/mapspeople/h0gdbmo4/1/" %}
{% endtab %}
-{% tab title="Mapbox - Manually" %}
+{% tab title="Mapbox v3 - Manually" %}
The MapsIndoors SDK is hosted on a Content Delivery Network (CDN) and should be loaded using a script tag.
Insert the MapsIndoors SDK script tag into ``, followed by the Mapbox `script` and `style` tag:
@@ -261,23 +269,23 @@ Insert the MapsIndoors SDK script tag into ``, followed by the Mapbox `scr
+
-
-
-
- MapsIndoors
-
-
-
+
+
+ MapsIndoors
+
+
+
+
-
+
+
```
-> Remember to add your API keys to the links in your code. You can use the demo MapsIndoors API key: `d876ff0e60bb430b8fabb145`.
-
Add an empty `
` element to `` with the `id` attribute set to "map":
```html
@@ -285,41 +293,50 @@ Add an empty `
` element to `` with the `id` attribute set to "map":
+
-
-
-
- MapsIndoors
-
-
-
+
+
+ MapsIndoors
+
+
+
+
-
-
+
+
+
```
-To load data and display it on the map, we need to create a new _instance_ of the [`MapsIndoors` class](https://app.mapsindoors.com/mapsindoors/js/sdk/latest/docs/mapsindoors.MapsIndoors.html#MapsIndoors) with a [`mapView` instance](https://app.mapsindoors.com/mapsindoors/js/sdk/latest/docs/mapsindoors.mapView.MapboxView.html) with a few _properties_ set. This is all done by placing the following code in the `main.js` file you created earlier:
+To load data and display it on the map, we need to create a new _instance_ of the [`MapsIndoors` class](https://app.mapsindoors.com/mapsindoors/js/sdk/latest/docs/mapsindoors.MapsIndoors.html#MapsIndoors) with a [`mapView` instance](https://app.mapsindoors.com/mapsindoors/js/sdk/latest/docs/mapsindoors.mapView.MapboxV3View.html) with a few _properties_ set. This is all done by placing the following code in the `script.js` file you created earlier:
+
+In the `script.js` code below, replace `YOUR_MAPSINDOORS_API_KEY` with your actual MapsIndoors API key. For testing, you can use the demo API key: `02c329e6777d431a88480a09`.
```javascript
-// main.js
+// script.js
const mapViewOptions = {
accessToken: 'YOUR_MAPBOX_ACCESS_TOKEN',
element: document.getElementById('map'),
- center: { lat: 38.8974905, lng: -77.0362723 }, // The White House
+ center: { lng: -97.74204591828197, lat: 30.36022358949809 }, // MapsPeople - Austin Office
zoom: 17,
- maxZoom: 22
+ maxZoom: 22,
+ mapsIndoorsTransitionLevel: 16,
};
-const mapViewInstance = new mapsindoors.mapView.MapboxView(mapViewOptions);
+
+//Set the MapsIndoors API key
+mapsindoors.MapsIndoors.setMapsIndoorsApiKey('YOUR_MAPSINDOORS_API_KEY');
+
+const mapViewInstance = new mapsindoors.mapView.MapboxV3View(mapViewOptions);
const mapsIndoorsInstance = new mapsindoors.MapsIndoors({
mapView: mapViewInstance,
});
```
-What happens in this snippet is we create a `mapViewInstance` that pulls up a [`MapboxView`](https://app.mapsindoors.com/mapsindoors/js/sdk/latest/docs/mapsindoors.mapView.MapboxView.html) with some [`mapViewOptions`](https://app.mapsindoors.com/mapsindoors/js/sdk/latest/docs/mapsindoors.mapView.MapboxView.html). The options define which element in the html-file to display the map in (in this case `
`), where the map should center, what zoom level to display, and what the max zoom level is.
+What happens in this snippet is we create a `mapViewInstance` that pulls up a [`MapboxView`](https://app.mapsindoors.com/mapsindoors/js/sdk/latest/docs/mapsindoors.mapView.MapboxV3View.html) with some [`mapViewOptions`](https://app.mapsindoors.com/mapsindoors/js/sdk/latest/docs/mapsindoors.mapView.MapboxV3View.html). The options define which element in the html-file to display the map in (in this case `
`), where the map should center, what zoom level to display, and what the max zoom level is. You can also control `mapsIndoorsTransitionLevel` which defines when Mapbox' Extruded buildings disappear and MapsIndoors data is shown. `lightPreset` sets the global [light](getting-started/prerequisites.md#mapbox-v3) for you application, while `showMapMarkers` property defines if Mapbox' Markers are shown on the map.
You should now see a map from your chosen map engine with MapsIndoors data loaded on top.
@@ -329,141 +346,39 @@ Next, we'll add a Floor Selector for changing between floors.
First, we add an empty `
` element programmatically. Then we create a new [`FloorSelector` _instance_](https://app.mapsindoors.com/mapsindoors/js/sdk/latest/docs/FloorSelector.html) and push the `floorSelectorElement` to the `mapboxInstance` to position it as a map controller:
-```javascript
-// main.js
-
-const mapViewOptions = {
- accessToken: 'YOUR_MAPBOX_ACCESS_TOKEN',
- element: document.getElementById('map'),
- center: { lat: 38.8974905, lng: -77.0362723 }, // The White House
- zoom: 17,
- maxZoom: 22
-};
-
-const mapViewInstance = new mapsindoors.mapView.MapboxView(mapViewOptions);
-const mapsIndoorsInstance = new mapsindoors.MapsIndoors({ mapView: mapViewInstance });
-const mapboxInstance = mapViewInstance.getMap();
-
-// Floor Selector
-const floorSelectorElement = document.createElement('div');
-new mapsindoors.FloorSelector(floorSelectorElement, mapsIndoorsInstance);
-mapboxInstance.addControl({ onAdd: function () { return floorSelectorElement }, onRemove: function () { } });
-```
-
-{% embed url="https://docs.mapbox.com/mapbox-gl-js/api/map/#map#addcontrol" %}
-
-> See all available control positions in the [Mapbox Documentation](https://docs.mapbox.com/mapbox-gl-js/api/map/#map#addcontrol).
-
-You should now be able to switch between floors.
-
-Here's a JSFiddle demonstrating the result you should have by now:
-
-[https://jsfiddle.net/mapspeople/o12hrcL8/6/](https://jsfiddle.net/mapspeople/o12hrcL8/6/)
-{% endtab %}
-
-{% tab title="Mapbox v3 - Manually" %}
-The MapsIndoors SDK is hosted on a Content Delivery Network (CDN) and should be loaded using a script tag.
-
-Insert the MapsIndoors SDK script tag into ``, followed by the Mapbox `script` and `style` tag:
-
-```html
-
-
-
-
-
-
-
-
- MapsIndoors
-
-
-
-
-
-
-
-
-```
-
-> Remember to add your API keys to the links in your code. You can use the demo MapsIndoors API key: `d876ff0e60bb430b8fabb145`.
-
-Add an empty `
` element to `` with the `id` attribute set to "map":
-
-```html
-
-
-
-
-
-
-
-
- MapsIndoors
-
-
-
-
-
-
-
-
-
-```
-
-To load data and display it on the map, we need to create a new _instance_ of the [`MapsIndoors` class](https://app.mapsindoors.com/mapsindoors/js/sdk/latest/docs/mapsindoors.MapsIndoors.html#MapsIndoors) with a [`mapView` instance](https://app.mapsindoors.com/mapsindoors/js/sdk/latest/docs/mapsindoors.mapView.MapboxV3View.html) with a few _properties_ set. This is all done by placing the following code in the `main.js` file you created earlier:
+In the `script.js` code below, replace `YOUR_MAPSINDOORS_API_KEY` with your actual MapsIndoors API key. For testing, you can use the demo API key: `02c329e6777d431a88480a09`.
```javascript
-// main.js
+// script.js
const mapViewOptions = {
accessToken: 'YOUR_MAPBOX_ACCESS_TOKEN',
element: document.getElementById('map'),
- center: { lat: 38.8974905, lng: -77.0362723 }, // The White House
+ center: { lng: -97.74204591828197, lat: 30.36022358949809 }, // MapsPeople - Austin Office
zoom: 17,
maxZoom: 22,
- mapsIndoorsTransitionLevel: 17,
- lightPreset: 'dusk',
- showMapMarkers: false
+ mapsIndoorsTransitionLevel: 16,
};
+
+//Set the MapsIndoors API key
+mapsindoors.MapsIndoors.setMapsIndoorsApiKey('YOUR_MAPSINDOORS_API_KEY');
+
const mapViewInstance = new mapsindoors.mapView.MapboxV3View(mapViewOptions);
const mapsIndoorsInstance = new mapsindoors.MapsIndoors({
mapView: mapViewInstance,
});
-```
-
-What happens in this snippet is we create a `mapViewInstance` that pulls up a [`MapboxView`](https://app.mapsindoors.com/mapsindoors/js/sdk/latest/docs/mapsindoors.mapView.MapboxV3View.html) with some [`mapViewOptions`](https://app.mapsindoors.com/mapsindoors/js/sdk/latest/docs/mapsindoors.mapView.MapboxV3View.html). The options define which element in the html-file to display the map in (in this case `
`), where the map should center, what zoom level to display, and what the max zoom level is. You can also control `mapsIndoorsTransitionLevel` which defines when Mapbox' Extruded buildings disappear and MapsIndoors data is shown. `lightPreset` sets the global [light](getting-started/prerequisites.md#mapbox-v3) for you application, while `showMapMarkers` property defines if Mapbox' Markers are shown on the map.
-
-You should now see a map from your chosen map engine with MapsIndoors data loaded on top.
-
-### Display a Floor Selector
-
-Next, we'll add a Floor Selector for changing between floors.
-
-First, we add an empty `
` element programmatically. Then we create a new [`FloorSelector` _instance_](https://app.mapsindoors.com/mapsindoors/js/sdk/latest/docs/FloorSelector.html) and push the `floorSelectorElement` to the `mapboxInstance` to position it as a map controller:
-
-```javascript
-// main.js
-
-const mapViewOptions = {
- accessToken: 'YOUR_MAPBOX_ACCESS_TOKEN',
- element: document.getElementById('map'),
- center: { lat: 38.8974905, lng: -77.0362723 }, // The White House
- zoom: 17,
- maxZoom: 22,
- mapsIndoorsTransitionLevel: 17,
- lightPreset: 'dusk',
- showMapMarkers: false
-};
-const mapViewInstance = new mapsindoors.mapView.MapboxV3View(mapViewOptions);
-const mapsIndoorsInstance = new mapsindoors.MapsIndoors({ mapView: mapViewInstance });
const mapboxInstance = mapViewInstance.getMap();
// Floor Selector
const floorSelectorElement = document.createElement('div');
new mapsindoors.FloorSelector(floorSelectorElement, mapsIndoorsInstance);
-mapboxInstance.addControl({ onAdd: function () { return floorSelectorElement }, onRemove: function () { } });
+mapboxInstance.addControl({
+ onAdd: function () {
+ return floorSelectorElement;
+ },
+ onRemove: function () { },
+});
```
{% embed url="https://docs.mapbox.com/mapbox-gl-js/api/map/#map#addcontrol" %}
@@ -471,6 +386,10 @@ mapboxInstance.addControl({ onAdd: function () { return floorSelectorElement },
> See all available control positions in the [Mapbox Documentation](https://docs.mapbox.com/mapbox-gl-js/api/map/#map#addcontrol).
You should now be able to switch between floors.
+
+Here's a CodeSandbox demonstrating the result you should have by now:
+
+{% embed url="https://codesandbox.io/p/sandbox/github/MapsPeople/mapsindoors-getting-started-for-web/tree/main/sdk/mapbox/1-display-a-map" %}
{% endtab %}
{% tab title="Mapbox - MI Components" %}
@@ -482,18 +401,17 @@ Insert script tag into ``:
```html
-
+
-
MapsIndoors
-
+
-
+
```
@@ -506,33 +424,33 @@ After you added the script tag into ``, add the `` custom e
+
-
MapsIndoors
-
+
-
+
-
+
```
-Remember to add your API keys where indicated. You can use the demo MapsIndoors API key: `d876ff0e60bb430b8fabb145`.
+Remember to add your API keys where indicated. You can use the demo MapsIndoors API key: `02c329e6777d431a88480a09`.
To center the map correctly, you need need the Mapbox _instance_ in your JavaScript-file.
First we get a reference to the `` element. Then we attach the [`mapsIndoorsReady`](https://app.mapsindoors.com/mapsindoors/js/sdk/latest/docs/mapsindoors.MapsIndoors.html#event:ready) event listener so we'll know when MapsIndoors is ready after loading. Lastly, on the `mapsIndoorsReady` event, get the Mapbox _instance_ and call its [`setCenter` method](https://docs.mapbox.com/mapbox-gl-js/api/map/#map#setcenter) to center the map on the loaded data:
```javascript
-// main.js
+// script.js
const miMapElement = document.querySelector('mi-map-mapbox');
miMapElement.addEventListener('mapsIndoorsReady', () => {
miMapElement.getMapInstance().then((mapInstance) => {
- mapInstance.setCenter([-77.0362723, 38.8974905]); // The White House
+ mapInstance.setCenter([-97.7412840716576, 30.359285384]); // MapsPeople - Austin Office
});
});
```
@@ -549,21 +467,20 @@ Using the `` element, you can add the [floorSelectorControlPositi
```html
-
+
-
MapsIndoors
-
+
-
+
-
+
```
@@ -595,20 +512,19 @@ MapsIndoors Locations can be retrieved in the MapsIndoors namespace using the [`
```html
-
+
-
MapsIndoors
-
+
-
-
+
+
@@ -621,11 +537,11 @@ MapsIndoors Locations can be retrieved in the MapsIndoors namespace using the [`
* Call the `getLocations` method and log out the results to the console.
```javascript
-// main.js
+// script.js
const mapViewOptions = {
element: document.getElementById('map'),
- center: { lat: 38.8974905, lng: -77.0362723 }, // The White House
+ center: { lat: 30.359285384, lng: -97.7412840716576 }, // MapsPeople - Austin Office
zoom: 17,
maxZoom: 22,
};
@@ -659,20 +575,19 @@ To display a list of search results you can append each search result to a list
```html
-
+
-
MapsIndoors
-
+
-
-
+
+
@@ -684,11 +599,11 @@ To display a list of search results you can append each search result to a list
* Reset the list on every complete search.
```javascript
-// main.js
+// script.js
const mapViewOptions = {
element: document.getElementById('map'),
- center: { lat: 38.8974905, lng: -77.0362723 }, // The White House
+ center: { lat: 30.359285384, lng: -97.7412840716576 }, // MapsPeople - Austin Office
zoom: 17,
maxZoom: 22,
};
@@ -717,11 +632,11 @@ function onSearch() {
* Add a _for_ loop and append every result to the search results list element.
```javascript
-// main.js
+// script.js
const mapViewOptions = {
element: document.getElementById('map'),
- center: { lat: 38.8974905, lng: -77.0362723 }, // The White House
+ center: { lat: 30.359285384, lng: -97.7412840716576 }, // MapsPeople - Austin Office
zoom: 17,
maxZoom: 22,
};
@@ -761,11 +676,11 @@ To filter the map to only display the search results you can use the `filter` me
* Call `mapsIndoorsInstance.filter` with an array of Location IDs.
```javascript
-// main.js
+// script.js
const mapViewOptions = {
element: document.getElementById('map'),
- center: { lat: 38.8974905, lng: -77.0362723 }, // The White House
+ center: { lat: 30.359285384, lng: -97.7412840716576 }, // MapsPeople - Austin Office
zoom: 17,
maxZoom: 22,
};
@@ -817,25 +732,28 @@ Using the `` component you get a ``element tied tightly togeth
```html
-
+
-
MapsIndoors
-
+
-
+
```
@@ -844,14 +762,14 @@ Using the `` component you get a ``element tied tightly togeth
* Attach an `results` event listener and log out the results to the console.
```javascript
-// main.js
+// script.js
const miMapElement = document.querySelector('mi-map-googlemaps');
const miSearchElement = document.querySelector('mi-search');
miMapElement.addEventListener('mapsIndoorsReady', () => {
miMapElement.getMapInstance().then((mapInstance) => {
- mapInstance.setCenter({ lat: 38.8974905, lng: -77.0362723 }); // The White House
+ mapInstance.setCenter({ lat: 30.359285384, lng: -97.7412840716576 }); // MapsPeople - Austin Office
});
})
@@ -866,34 +784,35 @@ For more information on available events and how to configure the ``
To display a list of search results you can append each search result to a list element.
-
-
* Insert the `` custom element below the search field in ``.
* Add the `scroll-buttons-enabled` and `scroll-length` attributes.
```html
-
+
-
MapsIndoors
-
+
-
+
-
+
-
+
```
@@ -904,7 +823,7 @@ For more information on how to configure the `` component, see [compone
* Reset the list on every complete search.
```javascript
-// main.js
+// script.js
const miMapElement = document.querySelector('mi-map-googlemaps');
const miSearchElement = document.querySelector('mi-search');
@@ -912,7 +831,7 @@ const miListElement = document.querySelector('mi-list');
miMapElement.addEventListener('mapsIndoorsReady', () => {
miMapElement.getMapInstance().then((mapInstance) => {
- mapInstance.setCenter({ lat: 38.8974905, lng: -77.0362723 }); // The White House
+ mapInstance.setCenter({ lat: 30.359285384, lng: -97.7412840716576 }); // MapsPeople - Austin Office
});
})
@@ -925,7 +844,7 @@ miSearchElement.addEventListener('results', (event) => {
* Add a _for_ loop and append every result to the search results list element.
```javascript
-// main.js
+// script.js
const miMapElement = document.querySelector('mi-map-googlemaps');
const miSearchElement = document.querySelector('mi-search');
@@ -933,7 +852,7 @@ const miListElement = document.querySelector('mi-list');
miMapElement.addEventListener('mapsIndoorsReady', () => {
miMapElement.getMapInstance().then((mapInstance) => {
- mapInstance.setCenter({ lat: 38.8974905, lng: -77.0362723 }); // The White House
+ mapInstance.setCenter({ lat: 30.359285384, lng: -97.7412840716576 }); // MapsPeople - Austin Office
});
})
@@ -957,7 +876,7 @@ To filter the map to only display the search results you can use the `filter` me
```javascript
-// main.js
+// script.js
const miMapElement = document.querySelector('mi-map-googlemaps');
const miSearchElement = document.querySelector('mi-search');
@@ -965,7 +884,7 @@ const miListElement = document.querySelector('mi-list');
miMapElement.addEventListener('mapsIndoorsReady', () => {
miMapElement.getMapInstance().then((mapInstance) => {
- mapInstance.setCenter({ lat: 38.8974905, lng: -77.0362723 }); // The White House
+ mapInstance.setCenter({ lat: 30.359285384, lng: -97.7412840716576 }); // MapsPeople - Austin Office
});
})
@@ -993,11 +912,10 @@ To remove the location filter again, call `mapsIndoorsInstance.filter(null)`.
Here's a JSFiddle demonstrating the result you should have by now:
{% embed url="https://jsfiddle.net/mapspeople/jtnw0u1y/1/" fullWidth="false" %}
-
-
{% endtab %}
{% tab title="Mapbox - Manually" %}
+
## Create a Simple Query Search
MapsIndoors Locations can be retrieved in the MapsIndoors namespace using the [`LocationsService.getLocations()` method](https://app.mapsindoors.com/mapsindoors/js/sdk/latest/docs/mapsindoors.services.LocationsService.html#.getLocations) but first you need to add an `` and `