You need to sign in to do that
Don't have an account?

google map not showing up on Visualforce page
Below is my page code,
<apex:page controller="SampleLocation">
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#map-canvas { height: 100% }
</style>
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?key=MY_API_KEY">
</script>
<script type="text/javascript">
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(-34.397, 150.644),
zoom: 8
};
var map = new google.maps.Map(document.getElementById("map-canvas"),
mapOptions);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="map-canvas"/>
</body>
</apex:page>
when I preview the page, nothing is shown.
when I save the exact same code in separate html file ( after removing apex:page tag) the code works just fine. I am sure that there is no issue with the API key.
any idea what is going wrong here ?
<apex:page controller="SampleLocation">
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#map-canvas { height: 100% }
</style>
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?key=MY_API_KEY">
</script>
<script type="text/javascript">
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(-34.397, 150.644),
zoom: 8
};
var map = new google.maps.Map(document.getElementById("map-canvas"),
mapOptions);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="map-canvas"/>
</body>
</apex:page>
when I preview the page, nothing is shown.
when I save the exact same code in separate html file ( after removing apex:page tag) the code works just fine. I am sure that there is no issue with the API key.
any idea what is going wrong here ?
This might help you. You are doing exactly the same thing.
I would also suggest to avoid the window onload event in case of visual force pages. At time salesforce has some native functions that gets called on the onload event. Adding a custom onload event at times messes them up. So please use the jQuery(document).ready() function.
Let me know if this helps.
Thanks,
Kaustav
in your style ? and check what happens ?