HelpNeeded
HelpNeeded

Reputation: 33

How to put a google map on JQUERY Mobile?

When tried to run the code , The map doesn't show up, and it shows up this error"Google Maps API warning: NoApiKeys ". What are the possible solution for this? This is the script that I have added:

<script src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>

These are the codes that I have put at the js file:

$(document).ready(function () {
                var myOptions = {
                    zoom: 11,
                    center: new google.maps.LatLng(1.363083, 103.909836),
                    mapTypeId: google.maps.MapTypeId.ROADMAP
                };
                var map = new google.maps.Map(document.getElementById('map_canvas'),
                        myOptions);

                var myLatlng = new google.maps.LatLng(1.443107  , 103.795681);
                var marker = new google.maps.Marker({
                    position: myLatlng,
                    map: map,
                    title: "Map "
                })
            });

Upvotes: 0

Views: 1301

Answers (1)

J Pagano
J Pagano

Reputation: 158

That error suggests that you haven't included an API key with your Google Maps api call. You need to go to https://developers.google.com/maps/, sign up for an API key, and include it in your call. Below is a really simple example using the JS api.

<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY></script>

Upvotes: 3

Related Questions