November 24, 201114 yr Hi there, I have the following code: var centerlat = 51.343225268175; var centerlng = -4.34317803278; var googleMap = null; var previousPos = null; var MIN_ZOOM_LEVEL = 19; var MAX_ZOOM_LEVEL = 21; $(function($){//Called when page is loaded googleMap = new google.maps.Map(document.getElementById("map_canvas"), { zoom: MIN_ZOOM_LEVEL, center: new google.maps.LatLng(centerlat, centerlng), mapTypeId: google.maps.MapTypeId.ROADMAP }); var tester = [ new google.maps.LatLng(51.343225268175, -4.3430012489791 ), new google.maps.LatLng(51.343243810758, -4.3430751462413 ), new google.maps.LatLng(51.343018092925, -4.3431956226451 ), new google.maps.LatLng(51.342999072325, -4.3431318564872 ), new google.maps.LatLng(51.343225268175, -4.3430012489791 ) ]; testerpoly = new google.maps.Polygon({ paths: tester, strokeColor: "#FF0000", strokeOpacity: 0.8, strokeWeight: 3, fillColor: "#FF0000", fillOpacity: 0.35 /////////////////////////THIS BIT PLZ HELP!!!///////////////////////// freetext: "blah" ////////////////////////////////////////////////////////////////////// }); testerpoly.setMap(googleMap); google.maps.event.addListener(testerpoly, 'click', showArrays); infowindow = new google.maps.InfoWindow(); function showArrays(event) { // Content string bit var contentString = "<b>Poly Clicked!</b><br />" + freetext; ///////// THIS BIT TOO!! // Replace our Info Window's content and position infowindow.setContent(contentString); infowindow.setPosition(event.latLng); infowindow.open(googleMap); } });//onload //]]> For some reason the "freetext" variable is not being translated to the showArrays function... I expect that this is a fairly simple thing to resolve and would very much appreciate your help! Thanks, tozj. Edited November 24, 201114 yr by tozjerimiah
November 24, 201114 yr Disclaimer: I'm really bad at JS. Still, main problem I can see is that freetext is a property of testerpoly, have you tried this: var contentString = "<b>Poly Clicked!</b><br />" + testerpoly.freetext;
November 24, 201114 yr Author Disclaimer: I'm really bad at JS. Still, main problem I can see is that freetext is a property of testerpoly, have you tried this: var contentString = "<b>Poly Clicked!</b><br />" + testerpoly.freetext; That works, but the issue that I have with it is that I am going to have many 'testerpoly's testerpoly1, testerpoly2, etc etc... so I would really like to have just one function that is called rather than having to make a new function per poly... thanks tho, you've shown me that there is hope!
Create an account or sign in to comment