javascript - Google Maps API v3 unable to center a map with a polyline marker -


i unable center google maps containing polyline marker after using setting display: none map container.

initially, map displayed correctly, after toggle hide() / show() map centered polyline marker on bottom-left corner. i've tried suggested solutions use google.maps.event.trigger(map, "resize"); didn't solve it.

the snippet. note initmap triggered on input change:

function initmap() {     mapcontainer = $("#mapcontainer");     mapobject = document.getelementbyid('map');      if (substance === "no2") {         mapcontainer.show();          var center = new google.maps.latlng(lat, lng);          map = new google.maps.map(mapobject, {             center: center,             zoom: 12,             maptypecontrol: false,             streetviewcontrol: false         });          const point = new google.maps.latlng(             parsefloat(lat),             parsefloat(lng)         );          var marker = new markerwithlabel({             position: point,             map: map,             draggable: true,             raiseondrag: true,             labelcontent: "123",             labelanchor: new google.maps.point(15, 65),             labelclass: "icon",             labelinbackground: false,             icon: {                 path: 'm 0,0 c -2,-20 -10,-22 -10,-30 10,10 0 1,1 10,-30 c 10,-22 2,-20 0,0 z',                 fillcolor: colorbackground,                 fillopacity: 1,                 strokecolor: colorborder,                 strokeweight: 1,                 scale: 2             }         });     } else {         $(mapcontainer).hide();     } } 


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -