jquery - Google Map Marker Is not in center -
I am implementing Google Maps API and I'm displaying a map in the jQuery dialog box. The map looks fine but the position of the marker not being interrupted, please guide me.
Code for the map: The code to open the code: HTML: Try the following: 1) Defined 2) Modify the "open" event of the dialog box to emphasize the map center while opening the dialog box: Try one and tell me that it works;)
var myCenter = new google.maps.LatLng ('@ model Lightside ',' @model.Longtud '); Function initialize () {var mapProp = {center: myCenter, Zoom: 15, map type EID: google.maps.MapTypeId.ROADMAP}; Var map = new google.maps.Map (document.getElementById ("googleMap"), mapProp); Var marker = new google.maps.marker ({status: myCenter, dragable: incorrect, animation: google.maps.Animation.DROP,}); Marker.setMap (map); }
$ ("# google map"). Dialog ({autoOpen: false (Height: 600), width: 1000, resize: work (event, UI) {google.maps.event.trigger (googleMap, 'resize')}, open: tasks (events, UI) {google.maps.event.trigger (GoogleMap, 'resize');},}); $ ("#btn location"). Click (function () {$ ("# googleMap"). Dialog ("Open");});
& lt; Div id = "google map" style = "width: 1000px; height: 500px" & gt; & Lt; / Div & gt; & Lt; Img src = "map.jpg" alt = "set location" id = "btnLocation" style = "cursor: indicator; height: 35px; width: 35px;" / & Gt;
map and
marker outside the function
initialize , we will call them later in the center of the map
var mycenter = new google.maps.LatLng ('model' lightitude ',' @ model.Longtude '); // your map and marker var map = faucet, marker = faucet; Function initialize () {var mapProp = {center: myCenter, Zoom: 15, map type EID: google.maps.MapTypeId.ROADMAP}; Map = new google.maps.Map (document.getElementById ("googleMap"), mapProp); Marker = new google.maps.marker ({status: myCenter, dragable: incorrect, animation: google.maps.Animation.DROP,}); Marker.setMap (map); }
$ ("#GoogleMap"). Dialog ({autoOpen: false, height: 600, width: 1000, resize: function (event, UI) {google.maps.event.trigger (googleMap, 'resize')}, // open event modified! Open: function (Event, UI) {google.maps.event.trigger (googleMap, 'resize'); // Force map center of map.setCenter (marker.getPosition ());},});
Comments
Post a Comment