-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi, I'm evaluating ZK 8 EE and I've been trying to get it to display a Google Map. I've used the example from the demo i.e.
<div apply="com.eg.MyMapController">
<script type="text/javascript" content="zk.googleAPIkey='MYKEY'" />
<gmaps version="3.26" id="gmaps" width="520px" height="400px" showSmallCtrl="true" protocol="https">
<ginfo id="info" open="true"
content="Hello, <a href="http://www.zkoss.org\">ZK</a>."/>
<gmarker id="marker" lat="51.508742" lng="-0.120850" open="true"
content="Hello, <a href="http://www.zkoss.org">ZK</a> on top of Gmarker."/>
</gmaps>
</div>
I registered for my key (MYKEY), put it in and tried to access on localhost. Javascript console warns about Missing API Key. Accessing from 127.0.0.1 or the machines IP shows a map of Palo Alto and gmarker coordinates are ignored. Console shows NoApiKeys warning. Looking at HTTP trace shows that the 'key' parameter is missing from the gmapz calls. Has anyone got this to work properly.
I got so frustrated with this I decided to write a simple HTML page as follows:
<!DOCTYPE html>
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<h1>My First Google Map</h1>
<div id="googleMap" style="width:100%;height:400px;"></div>
<script>
function myMap() {
var mapProp= {
center:new google.maps.LatLng(51.508742,-0.120850),
zoom:5,
};
var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=MYKEY"></script>
</body>
</html>
This worked first go. Any ideas??
Thanks
Please use ZK Gmaps 3.0.4 (as maven version or download) which adapts to the latest changes in the google maps API. This was implemented in the issue: http://tracker.zkoss.org/projects/ZKGMAPS/issues/ZKGMAPS-12
BTW: Which demo are you referring to that still uses an old version so we can correct the download package?
Robert
Asked: 2017-05-01 11:44:32 +0800
Seen: 42 times
Last updated: May 04 '17