{"id":12,"date":"2012-11-11T11:22:09","date_gmt":"2012-11-11T11:22:09","guid":{"rendered":"http:\/\/ramandv.com\/blog\/?p=12"},"modified":"2013-07-04T08:20:13","modified_gmt":"2013-07-04T08:20:13","slug":"using-google-maps-with-angularjs","status":"publish","type":"post","link":"http:\/\/www.ramandv.com\/blog\/using-google-maps-with-angularjs\/","title":{"rendered":"Using Google maps with AngularJS and Angular UI"},"content":{"rendered":"\n<!-- Quick Adsense WordPress Plugin: http:\/\/quickadsense.com\/ -->\n<div class=\"e9e85ee105af8a6a4a383deebf1fa216\" data-index=\"1\" style=\"float: none; margin:10px 0 10px 0; text-align:center;\">\n<script type=\"text\/javascript\"><!--\r\ngoogle_ad_client = \"ca-pub-4917982260456644\";\r\n\/* ramandv.com-ad1 *\/\r\ngoogle_ad_slot = \"9226290554\";\r\ngoogle_ad_width = 728;\r\ngoogle_ad_height = 90;\r\n\/\/-->\r\n<\/script>\r\n<script type=\"text\/javascript\"\r\nsrc=\"http:\/\/pagead2.googlesyndication.com\/pagead\/show_ads.js\">\r\n<\/script>\n<\/div>\n<p>You can use AngularUI to integrate Google Maps in your angularjs app. The following code snippet shows a simple example of Google maps with Angular UI.<\/p>\n<p>To hookup the events with map elements such as marker, polyline, you need to create html div elements with existing Google maps objects. It is a bit confusing part, but it helps to keep your controller free from adding listener codes.<\/p>\n<pre><code>\/\/Add the requried module 'angular-ui' as a dependency\nangular.module('maptesting', ['ui']);\n\nfunction MapCtrl($scope) {\n    var ll = new google.maps.LatLng(13.0810, 80.2740);\n    $scope.mapOptions = {\n        center: ll,\n        zoom: 15,\n        mapTypeId: google.maps.MapTypeId.ROADMAP\n    };\n\n    \/\/Markers should be added after map is loaded\n    $scope.onMapIdle = function() {\n        if ($scope.myMarkers === undefined){\n            var marker = new google.maps.Marker({\n                map: $scope.myMap,\n                position: ll\n            });\n            $scope.myMarkers = [marker, ];\n        }\n    };\n\n    $scope.markerClicked = function(m) {\n        window.alert(\"clicked\");\n    };\n\n}\u200b\n<\/code><\/pre>\n<hr \/>\n<pre><code>&lt;div ng-app='maptesting'&gt;\n    &lt;div ng-controller=\"MapCtrl\"&gt;\n        &lt;div id=\"map_canvas\" ui-map=\"myMap\" \n      style=\"height:300px;width:400px;border:2px solid #777777;margin:3px; border:1px solid\" \n      ui-options=\"mapOptions\" \n      ui-event=\"{'map-idle' : 'onMapIdle()'}\"\n      &gt;\n        &lt;\/div&gt;\n\n        &lt;!--In addition to creating the markers on the map, \n       div elements with existing google.maps.Marker object \n        should be created to hook up with events --&gt;\n        &lt;div ng-repeat=\"marker in myMarkers\" ui-map-marker=\"myMarkers[$index]\"\n                      ui-event=\"{'map-click': 'markerClicked(marker)'}\"&gt;\n        &lt;\/div&gt;\n    &lt;\/div&gt;\n&lt;\/div&gt;\n<\/code><\/pre>\n<p><strong>JS Fiddle<\/strong><\/p>\n<p><a href=\"http:\/\/jsfiddle.net\/ramandv\/xSPAA\/\" title=\"http:\/\/jsfiddle.net\/ramandv\/xSPAA\/\">http:\/\/jsfiddle.net\/ramandv\/xSPAA\/<\/a><\/p>\n\n<div style=\"font-size: 0px; height: 0px; line-height: 0px; margin: 0; padding: 0; clear: both;\"><\/div>","protected":false},"excerpt":{"rendered":"<p>You can use AngularUI to integrate Google Maps in your angularjs app. The following code snippet shows a simple example of Google maps with Angular UI. To hookup the events with map elements such as marker, polyline, you need to &hellip; <a href=\"http:\/\/www.ramandv.com\/blog\/using-google-maps-with-angularjs\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[7,6],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v17.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.ramandv.com\/blog\/using-google-maps-with-angularjs\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using Google maps with AngularJS and Angular UI - Articles for Developers\" \/>\n<meta property=\"og:description\" content=\"You can use AngularUI to integrate Google Maps in your angularjs app. The following code snippet shows a simple example of Google maps with Angular UI. To hookup the events with map elements such as marker, polyline, you need to &hellip; Continue reading &rarr;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.ramandv.com\/blog\/using-google-maps-with-angularjs\/\" \/>\n<meta property=\"og:site_name\" content=\"Articles for Developers\" \/>\n<meta property=\"article:published_time\" content=\"2012-11-11T11:22:09+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2013-07-04T08:20:13+00:00\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"ramandv\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"http:\/\/www.ramandv.com\/blog\/#website\",\"url\":\"http:\/\/www.ramandv.com\/blog\/\",\"name\":\"Articles for Developers\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/www.ramandv.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.ramandv.com\/blog\/using-google-maps-with-angularjs\/#webpage\",\"url\":\"https:\/\/www.ramandv.com\/blog\/using-google-maps-with-angularjs\/\",\"name\":\"Using Google maps with AngularJS and Angular UI - Articles for Developers\",\"isPartOf\":{\"@id\":\"http:\/\/www.ramandv.com\/blog\/#website\"},\"datePublished\":\"2012-11-11T11:22:09+00:00\",\"dateModified\":\"2013-07-04T08:20:13+00:00\",\"author\":{\"@id\":\"http:\/\/www.ramandv.com\/blog\/#\/schema\/person\/ca1ede7143462f244081566e6ff97658\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.ramandv.com\/blog\/using-google-maps-with-angularjs\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.ramandv.com\/blog\/using-google-maps-with-angularjs\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.ramandv.com\/blog\/using-google-maps-with-angularjs\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Using Google maps with AngularJS and Angular UI\"}]},{\"@type\":\"Person\",\"@id\":\"http:\/\/www.ramandv.com\/blog\/#\/schema\/person\/ca1ede7143462f244081566e6ff97658\",\"name\":\"ramandv\",\"url\":\"http:\/\/www.ramandv.com\/blog\/author\/ramandv\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.ramandv.com\/blog\/using-google-maps-with-angularjs\/","og_locale":"en_US","og_type":"article","og_title":"Using Google maps with AngularJS and Angular UI - Articles for Developers","og_description":"You can use AngularUI to integrate Google Maps in your angularjs app. The following code snippet shows a simple example of Google maps with Angular UI. To hookup the events with map elements such as marker, polyline, you need to &hellip; Continue reading &rarr;","og_url":"https:\/\/www.ramandv.com\/blog\/using-google-maps-with-angularjs\/","og_site_name":"Articles for Developers","article_published_time":"2012-11-11T11:22:09+00:00","article_modified_time":"2013-07-04T08:20:13+00:00","twitter_misc":{"Written by":"ramandv","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebSite","@id":"http:\/\/www.ramandv.com\/blog\/#website","url":"http:\/\/www.ramandv.com\/blog\/","name":"Articles for Developers","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/www.ramandv.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.ramandv.com\/blog\/using-google-maps-with-angularjs\/#webpage","url":"https:\/\/www.ramandv.com\/blog\/using-google-maps-with-angularjs\/","name":"Using Google maps with AngularJS and Angular UI - Articles for Developers","isPartOf":{"@id":"http:\/\/www.ramandv.com\/blog\/#website"},"datePublished":"2012-11-11T11:22:09+00:00","dateModified":"2013-07-04T08:20:13+00:00","author":{"@id":"http:\/\/www.ramandv.com\/blog\/#\/schema\/person\/ca1ede7143462f244081566e6ff97658"},"breadcrumb":{"@id":"https:\/\/www.ramandv.com\/blog\/using-google-maps-with-angularjs\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.ramandv.com\/blog\/using-google-maps-with-angularjs\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.ramandv.com\/blog\/using-google-maps-with-angularjs\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Using Google maps with AngularJS and Angular UI"}]},{"@type":"Person","@id":"http:\/\/www.ramandv.com\/blog\/#\/schema\/person\/ca1ede7143462f244081566e6ff97658","name":"ramandv","url":"http:\/\/www.ramandv.com\/blog\/author\/ramandv\/"}]}},"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p6YZCe-c","_links":{"self":[{"href":"http:\/\/www.ramandv.com\/blog\/wp-json\/wp\/v2\/posts\/12"}],"collection":[{"href":"http:\/\/www.ramandv.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.ramandv.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.ramandv.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.ramandv.com\/blog\/wp-json\/wp\/v2\/comments?post=12"}],"version-history":[{"count":41,"href":"http:\/\/www.ramandv.com\/blog\/wp-json\/wp\/v2\/posts\/12\/revisions"}],"predecessor-version":[{"id":147,"href":"http:\/\/www.ramandv.com\/blog\/wp-json\/wp\/v2\/posts\/12\/revisions\/147"}],"wp:attachment":[{"href":"http:\/\/www.ramandv.com\/blog\/wp-json\/wp\/v2\/media?parent=12"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.ramandv.com\/blog\/wp-json\/wp\/v2\/categories?post=12"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.ramandv.com\/blog\/wp-json\/wp\/v2\/tags?post=12"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}