How do I add a google map to a dojox mobile view?

若如初见. 提交于 2019-12-02 17:23:16

问题


I am unable to successfully add a google map to my dojo mobile application.

I have the following element in markup:

<div id="venue" dojotype="dojox.mobile.View" style="height:100%">
        <div id="map_canvas" style="width:100%; height:100%"></div>
</div>

And this script:

function initializeMap() {
   var latlng = new google.maps.LatLng(-34.397, 150.644);
   var myOptions = {
   zoom: 8,
   center: latlng,
   mapTypeId: google.maps.MapTypeId.ROADMAP
   };
   var node = dojo.byId("map_canvas");
   var map = new google.maps.Map(node, myOptions);
}

Nothing appears when I execute the initializeMap function. I also tried to set the map variable to the node.innerHTML but only a sliver of the map appears on the top of the viewport.

The example in the dojo site only shows the source of the markup and not the script. What am I missing, please?


回答1:


Here's snippets of HTML/Javascript I was able to get working.

Details
var latlng = new google.maps.LatLng(item.Latitude, item.Longitude);
if (global.map == null) {
    var myOptions = {
          zoom: 16,
          center: latlng,
          mapTypeId: google.maps.MapTypeId.ROADMAP
        };
  global.map = new google.maps.Map(dojo.byId('map_canvas'), myOptions);
} else {
  global.map.setCenter(latlng);
}
var view = dijit.byId('ObjectsListView');
view.performTransition('ObjectDetailView', 1, 'slide');


来源:https://stackoverflow.com/questions/6642788/how-do-i-add-a-google-map-to-a-dojox-mobile-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!