16
loading...
This website collects cookies to deliver better user experience
npm install -g @ionic/cli
ionic start
"Integrate your new app with Capacitor to target native iOS and Android? (y/N)"
is prompted, Choose (y) and wait until the template is completely generated.npm install @angular/google-maps
code .
To open the project on VSCode, and, once inside it, type on terminal ionic serve
to check if our template is up and running. If everything went ok, you'll see at http://localhost:8100 this image which emulates a mobile device on browser after pressing F12 key:index.html
and<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY"></script>
folder.module.ts
file add GoogleMapsModule to imports.div
with id=container
replace the code with the following:<google-map
height="500px"
width="500px"
>
</google-map>
folder.page.ts
a variable center
and set longitude and latitude attributes like this:center = new google.maps.LatLng(-8.063242, -34.871048);
<google-map
height="700px"
width="500px"
[center]="center"
>
</google-map>
center
variable.{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"marker-color": "#7e7e7e",
"marker-size": "medium",
"marker-symbol": "",
"title": "Marco Zero",
"cat": "mustsee"
},
"geometry": {
"type": "Point",
"coordinates": [
-34.871112406253815,
-8.063165383068121
]
}
},
{
"type": "Feature",
"properties": {
"marker-color": "#7e7e7e",
"marker-size": "medium",
"marker-symbol": "",
"title": "Malakoff Tower",
"cat": "mustsee"
},
"geometry": {
"type": "Point",
"coordinates": [
-34.87082004547119,
-8.060759318240265
]
}
},
{
"type": "Feature",
"properties": {
"marker-color": "#7e7e7e",
"marker-size": "medium",
"marker-symbol": "",
"title": "Cais do Sertão Museum",
"cat": "mustsee"
},
"geometry": {
"type": "Point",
"coordinates": [
-34.87032651901245,
-8.061216099860022
]
}
},
{
"type": "Feature",
"properties": {
"marker-color": "#7e7e7e",
"marker-size": "medium",
"marker-symbol": "",
"title": "Kahal-Zur-Israel Sinagoge",
"cat": "mustsee"
},
"geometry": {
"type": "Point",
"coordinates": [
-34.87139403820038,
-8.06174192922556
]
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [
-34.871858060359955,
-8.061085970265072
]
}
}
]
}
tsconfig.json
file and on compilerOptions add:"resolveJsonModule": true, "esModuleInterop": true
import points from './points.json'
<map-marker
*ngFor="let marker of markers"
[position]="marker.position"
[label]="marker.label"
[title]="marker.title"
[options]="marker.options"
>
</map-marker>
16