Google Map Directive in Ionic
How do I make an google map directive in ionic?
Using two tabs with a google maps directive in each one and as soon as the two maps are rendered in the page. What is a google map directive in ionic? How do you make a google map directive in ionic? This script and codes were developed by Aaron K Saunders on 25 September 2022, Sunday.
Google Map Directive in Ionic - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Google Map Directive in Ionic</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <html ng-app="ionicApp"> <head> <meta charset="utf-8"> <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width"> <title>Tabs Example</title> <link href="https://code.ionicframework.com/nightly/css/ionic.min.css" rel="stylesheet"> <link href='https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,800,600,300,700' rel='stylesheet' type='text/css'> <script src="https://code.ionicframework.com/nightly/js/ionic.bundle.min.js"></script> <script src="https://maps.googleapis.com/maps/api/js?libraries=weather,visualization&sensor=false&language=en&v=3.14"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore-min.js"></script> <script src="https://rawgithub.com/nlaplante/angular-google-maps/master/dist/angular-google-maps.min.js"></script> </head> <body> <ion-nav-bar animation="nav-title-slide-ios7" class="bar-positive"> <ion-nav-back-button class="button-icon ion-arrow-left-c"> </ion-nav-back-button> </ion-nav-bar> <ion-nav-view animation="slide-left-right"></ion-nav-view> <script id="tabs.html" type="text/ng-template"> <ion-tabs tabs-type="tabs-icon-top" tabs-style="tabs-positive"> <ion-tab title="MAP ONE" icon="ion-home" href="#/tab/home"> <ion-nav-view name="home-tab"></ion-nav-view> </ion-tab> <ion-tab title="MAP TWO" icon="ion-ios7-information" href="#/tab/about" > <ion-nav-view name="about-tab"></ion-nav-view> </ion-tab> </ion-tabs> </script> <script id="home.html" type="text/ng-template"> <ion-view title="MAP ONE" ng-if="onTabOne" > <ion-content has-header="true" has-tabs="true" padding="true"> <button ng-click="hideMap = !hideMap">HIDE MAP</button> <button ng-click="addMarker()">ADD MARKER</button> <google-map center="center" zoom="zoom" > <markers models='markers' coords="'self'" icon='map.marker.icon' click="'onClicked'"> <windows show="'showWindow'" closeClick="'closeClick'" ng-cloak> <p ng-non-bindable>This is an info window at {{ latitude | number:4 }}, {{ longitude | number:4 }}!</p> <p class="muted" ng-non-bindable>{{title}}!</p> </windows> </markers> </google-map> </ion-nav-view > </ion-view> </script> <script id="about.html" type="text/ng-template"> <ion-view title="MAP TWO" ng-if="onTabTwo"> <ion-content has-header="true" has-tabs="true" padding="true"> <div > <google-map id='map2' center="center" zoom="zoom"> <markers models='markers' coords="'self'" icon='map.marker.icon'> <windows show="'showWindow'" closeClick="'closeClick'" ng-cloak> <p ng-non-bindable>This is an info window at {{ latitude | number:4 }}, {{ longitude | number:4 }}!</p> <p class="muted">My marker will stay open when the window is popped up!</p> </windows> </markers> </google-map> </div> </ion-content> </ion-view> </script> </body>
</html> <script src="js/index.js"></script>
</body>
</html>
Google Map Directive in Ionic - Script Codes CSS Codes
.angular-google-map-container { height: 400px; }
.marker-labels { color: red; background-color: white; font-family: "Lucida Grande", "Arial", sans-serif; font-size: 10px; font-weight: bold; text-align: center; width: 40px; border: 1px solid black; white-space: nowrap;
}
.angular-google-map { display: block; }
Google Map Directive in Ionic - Script Codes JS Codes
angular.module('ionicApp', ['ionic','google-maps'])
.config(function($stateProvider, $urlRouterProvider) { $stateProvider .state('tabs', { url: "/tab", abstract: true, templateUrl: "tabs.html" }) .state('tabs.home', { url: "/home", views: { 'home-tab': { templateUrl: "home.html", controller: 'HomeTabCtrl' } } }) .state('tabs.about', { url: "/about", views: { 'about-tab': { templateUrl: "about.html", controller: 'AboutTabCtrl' } } }); $urlRouterProvider.otherwise("/tab/home");
})
.controller('AboutTabCtrl', function($scope,$log) { $scope.onTabTwo = true; $scope.onTabOne = false; angular.extend($scope, { center: { latitude: 45, longitude: -73 }, markers: [], zoom: 8 }); $scope.map = {};
})
.controller('HomeTabCtrl', function($scope,$log, $timeout) { angular.extend($scope, { center: { latitude: 38.89, longitude: -77.13, }, markers: [{ latitude: 38.89, longitude: -77.00, title: 'Marker 2' }], zoom:8 }); $scope.map = { }; $scope.onTabTwo = false; $scope.onTabOne = true; google.maps.visualRefresh = true; var onMarkerClicked = function (marker) { debugger; marker.showWindow = true; //window.alert("Marker: lat: " + marker.latitude + ", lon: " + marker.longitude + " clicked!!") }; $scope.addMarker = function() { var m = { latitude: 38.89, longitude: -77.03, title: 'm ' + new Date(), /* closeClick : function () { m.showWindow = false; $scope.$apply(); }, onClicked : function () { onMarkerClicked(m); }*/ }; $scope.markers.push(m); $log.log('$scope.markers ' + $scope.markers); alert('added'); };
});
Developer | Aaron K Saunders |
Username | aaronksaunders |
Uploaded | September 25, 2022 |
Rating | 3 |
Size | 3,479 Kb |
Views | 42,504 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Angular2 Http Example | 3,851 Kb |
Ionic 2 Tabs Starter | 3,059 Kb |
Nested ng-repeat in AngularJS with Checkboxes | 2,600 Kb |
Firebase Login Example | 2,682 Kb |
Leaflet Map Directive in Ionic | 2,517 Kb |
A Pen by aaron k saunders | 2,286 Kb |
Demo ui-router basic state change | 2,042 Kb |
Promise sample for Cross-Platform mobile application class | 2,214 Kb |
A Pen by aaron k saunders | 4,143 Kb |
A Pen by aaron k saunders | 2,916 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Flexbox Test | Icutpeople | 2,486 Kb |
Fun animations with CSS3 | Minimalmonkey | 2,360 Kb |
SVG Basics | HipsterBrown | 1,852 Kb |
Two column of responsive height | Fixie | 2,908 Kb |
CSS Hover Effects | Alen | 3,613 Kb |
Atom | Bhlaird | 1,932 Kb |
Zeichensatz | Moklick | 2,058 Kb |
Parallax scrolling scene | Iharosi | 2,485 Kb |
Airbnb Homepage | SindhujaD | 2,480 Kb |
Find The Penguin | Lelder | 2,212 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!