2017-04-08 1 views
0

マップをレンダリングするために私のSymfony3プロジェクトでIvoryGoogleMapBundleを使用しています。コントローラに$mapオブジェクトを設定し、私の小枝ファイルにこの文を使用した後...IvoryGoogleMapBundle:レンダリング後にGoogleマップオブジェクトにアクセスする方法

{{ ivory_google_map(map) }} 
{{ ivory_google_api([map]) }} 

それはそのような何かを作り出す...私はいくつかのプロパティに到達することができますJavaScriptコンソールから今

<div id="map_canvas" style="width: 100%;height: 100vh;"></div> 
<style type="test/css"> 
    #map_canvas { 
    width: 100%; 
    height: 100vh; 
    } 
</style> 
<script type="text/javascript"> 
    function ivory_google_map_map58e92cb0aa95e139417147() { 
    map58e92cb0aa95e139417147_container = { 
     "base": { 
      "coordinates": [], 
      "bounds": [], 
      "points": [], 
      "sizes": [] 
     }, 
     "map": null, 
     "overlays": { 
      "icons": [], 
      "symbols": [], 
      "icon_sequences": [], 
      "circles": [], 
      "encoded_polylines": [], 
      "ground_overlays": [], 
      "polygons": [], 
      "polylines": [], 
      "rectangles": [], 
      "info_windows": [], 
      "info_boxes": [], 
      "marker_shapes": [], 
      "markers": [], 
      "marker_cluster": null 
     }, 
     "layers": { 
      "heatmap_layers": [], 
      "kml_layers": [] 
     }, 
     "events": { 
      "dom_events": [], 
      "dom_events_once": [], 
      "events": [], 
      "events_once": [] 
     }, 
     "functions": [] 
    }; 
    map58e92cb0aa95e139417147_container.functions.info_windows_close = function() {}; 
    map58e92cb0aa95e139417147_container.functions.to_array = function (o) { 
     var a = []; 
     for (var k in o) { 
      a.push(o[k]); 
     } 
     return a; 
    }; 
    map58e92cb0aa95e139417147_container.base.coordinates.coordinate58e92cb0aaca1311661317 = coordinate58e92cb0aaca1311661317 = new google.maps.LatLng(40.416862923413, -3.7034607678652, true); 
    map58e92cb0aa95e139417147_container.map = map58e92cb0aa95e139417147 = new google.maps.Map(document.getElementById("map_canvas"), { 
     "fullscreenControl": true, 
     "fullscreenControlOptions": { 
     "position": google.maps.ControlPosition.RIGHT_TOP 
    }, 
     "mapTypeId": google.maps.MapTypeId.HYBRID, 
     "zoom": 5 
    }); 
    map58e92cb0aa95e139417147.setCenter(coordinate58e92cb0aaca1311661317); 

    } 
</script> 

<script type="text/javascript"> 
    function ivory_google_map_load() { 
    google.load("maps", "3", { 
     "other_params": "language=en&key=__MY_API_KEY__, 
     "callback": ivory_google_map_init 
    }) 
    }; 
    function ivory_google_map_init_source (src) { 
    var script = document.createElement("script"); 
    script.type = "text/javascript"; 
    script.async = true; 
    script.src = src; 
    document.getElementsByTagName("head")[0].appendChild(script); 
    }; 
    function ivory_google_map_init_requirement (c, r) { 
    if (r()) { 
     c(); 
    } else { 
     var i = setInterval(function() { 
      if (r()) { 
       clearInterval(i); 
       c(); 
      } 
     }, 100); 
    } 
    }; 
    function ivory_google_map_init() { 
    ivory_google_map_init_requirement(ivory_google_map_map58e92cb0aa95e139417147, function() { 
     return typeof google.maps !== typeof undefined; 
    }); 
    }; 
    ivory_google_map_init_source("https://www.google.com/jsapi?callback=ivory_google_map_load"); 
</script> 

、使用して境界のような...

map58e92cb0aa95e139417147_container.map.getBounds().getNorthEast().lat(); 
>> 48.2861355244946 

しかし、マップコンテナオブジェクトは、どのように私は名前が順番にいくつかのJavaScriptを書くために推測することができ、各レンダリングにランダムな名前を持っているので、...地図で遊ぶ?

答えて

0

ライブラリには変数名を割り当てる方法しかありません。ただ、これをやって

...

$map = new Map(); 
$map->setVariable('my_map'); 

と私は

my_map.getBounds().getNorthEast().lat(); 

簡単にやってJavaScriptでプロパティにアクセスすることができます!

関連する問題