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:

  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); }   

The code to open the code:

  $ ("# 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");});   

HTML:

  & 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;    

Try the following:

1) Defined 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); }   

2) Modify the "open" event of the dialog box to emphasize the map center while opening the dialog box:

  $ ("#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 ());},});   

Try one and tell me that it works;)

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -