When i click the text. google map will draw on modal pop up in bootstrap
Here google map is created and location is point out by marker. marker placed in left top corner. not in center position.
Calling the google map
td_location.innerHTML = '<span data-toggle="modal" data-target="#map"><img src="img/marker.png" class="add_marker" onclick="createMap('+json_obj.devices[i].latitude+','+json_obj.devices[i].longitude+')"/></span>'
google map creation
function createMap(lat,lng)
{
var mapOptions={
zoom:10,
//center:new google.maps.LatLng(lat, lng)
};
map=new google.maps.Map(document.getElementById('locationMap'),mapOptions);
var pos=new google.maps.LatLng(lat,lng);
var marker = new google.maps.Marker({
position: pos,
map: map,
});
map.setCenter(pos);
return true;
}
google.maps.event.addListenerOnce(map, 'idle', function(){
google.maps.event.trigger(map, 'resize');
map.setCenter(pos);
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.