GoogleMapsAPI implementation doesn't publish the map in the directory template. Here is the markup and code

GoogleMapsAPI实现不会在目录模板中发布映射。这是标记和代码

<gmap-locator></gmap-locator>   

.

app.directive('gmapLocator', function () {
    var link = function (scope, element, attrs) {
                var map, mapOptions, markers;
                var lat = scope.mapParameters.initialSettings.Lat;
                var lng = scope.mapParameters.initialSettings.Lng;
                mapOptions = {
                    mapTypeId : google.maps.MapTypeId.ROADMAP,
                    center: new google.maps.LatLng(lat, lng),
                    zoom: scope.mapParameters.initialSettings.zoom
                };


                function initMap() {
                    if (map === void 0) {
                        map = new google.maps.Map(element[0], mapOptions);

                    }
                }
                initMap();
            }
            return {
                restrict: 'EA',
                scope: {
                    mapParameters: '='
                },
                template: "<div id='gomap' style='height: 400px;width:300px'></div>",
                controller: controller,
                link: link
            }
            return {
                restrict: 'EA',
                template: '<div id="gomap" style="width: 450px;height:400px;"></div>',
                link: link
            };
        });

Google Maps library doesn't detect the target div and publish the map..

Google地图库未检测到目标div并发布地图。

1 个解决方案

#1


this is happening because <div id="gomap".. is published a child element to the directive element <gmap-locator map-parameters="mapParameters"></gmap-locator> So the GoogleMaps initialization code in the initmap function should be changed to

这是因为

所以initmap函数中的GoogleMaps初始化代码应该改为

更多相关文章

  1. Aptana Studio 3 IDE中有运行JavaScript代码的方法吗?
  2. 如何在JavaScript中编写适当的OOP代码?
  3. 高性能JavaScript代码高亮插件
  4. js“DOM事件”之鼠标事件、js的测试方法、js代码的放置位置
  5. 使用Node.js初始化和配置AWS
  6. JavaScript 最佳实践:帮你提升代码质量
  7. 关于JavaScript变量声明及其初始化的问题
  8. 利用javascript实现遍历xml文件的代码实例
  9. javascript 的MD5代码备份,跟java互通

随机推荐

  1. excel 中设置下拉菜单,让其一直显示
  2. 这件正在发生的事,关乎所有的Python开发者
  3. python入门教程12-06 (python语法入门之进
  4. 如何使用visual studio 2017
  5. 最新进展|关于Python治理模式的投票
  6. IP及基本配置
  7. 为什么range不是迭代器?range到底是什么类
  8. 在excel 中添加表单控件
  9. Python对象的空间边界:独善其身与开放包容
  10. Spark Streaming 使用