Showing info window outside the google map -
i have implemented google map zip code polygons i.e drawing zip code polygons on map using different zip code co-ordinates. on zip code polygons showing market markers. when click either on zip code polygon or market marker displays info window containing respective data. window opens inside map, pointing corresponding zip code/market marker. have requirement have show info window outside map irrespective of zip code/marker. keep fixed area(may div) outside map, , when click of zip code polygon, info window display inside fixed area. how can it.
my working code
var path = [ {% polycoord in zip.zip_info.zip_polygon %} new google.maps.latlng({{polycoord.1}}, {{polycoord.0}}), {% endfor %} ]; var polygon = new google.maps.polygon( { path:path, clickable:true, strokecolor: '#000000', strokeopacity: 0.75, strokeweight: 1, fillcolor: '#333fff', fillopacity: 1, } ); google.maps.event.addlistener(polygon, 'click', function (event) { $.ajax({ type: "get", url: get_data, data: datastring, success: function(res) { if(res != '') { var contentstring = res; var infowindow = new google.maps.infowindow( { content: contentstring }); infowindow.setposition(event.latlng); infowindow.open(map); google.maps.event.addlistener(map, 'click', function() { infowindow.close(); }); } else { alert('no data found') } } }); });
should work (if existing code does), not tested.
google.maps.event.addlistener(polygon, 'click', function (event) { $.ajax({ type: "get", url: get_data, data: datastring, success: function(res) { if(res != '') { var contentstring = res; document.getelementbyid('theidofyourdiv').innerhtml = res; } else { alert('no data found') } } }); });
Comments
Post a Comment