[HEEEEELP !!!!!!] Google Maps

0 favourites
From the Asset Store
Google Analytics 4 Plugin for Construct 3 enables metrics and analytics for your games easily.
  • Hi, this is the first of two questions about using C2 as tool to make something little different from games :

    So, question 1 :

    Ho to make little window invoking and showing google maps with current user position ?

    Thanks !


  • I see you had made two different posts, for two different questions. Couldn't you just make one post for both questions?

    For Google Maps, you can use a JavaScript function to allow use of Google Maps with C2 using this Plugin: http://www.scirra.com/forum/plugin-call-javascript_topic45866.html.

    This plugin enables you to call a external JavaScript file outside C2.

  • GameThirsty , thanks for the answer. I thought it was better to separate questions for a logic reason....

    Anyway, i checked the link you provided and i'll soon try it. Thanks !

    The script i'll have to insert is a simple google maps invocation showing current position of user . Like this :


    navigator.geolocation.getCurrentPosition (function (pos)


    var lat = pos.coords.latitude;

    var lng = pos.coords.longitude;

    var myLatLng = new google.maps.LatLng(lat,lng);


    var marker = new google.maps.Marker({

                     map: control.map,

                     position: myLatLng


    control.center = myLatLng;




    Hoping it will work. I'll report you soon . Thanks !


  • GameThirsty

    what's wrong with my code? :(


    i have errore "google" is not defined. Isn't it html5 standard ?



  • GameThirsty

    UP ?


  • Try this code out:

    function openZip(zipcode)


    if (zipcode == '') alert('No postcode entered');

    else window.open ('http://maps.google.co.uk/maps?q=' + zipcode + '&iwloc=A&hl=en','zipcode');


    Then inside a text box put openZip("1010 Vienna")

    The 1010 Vienna is a zip code for an area, you can modify this to your liking.

    I know its not perfect, I am not a pro at JavaScript.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • GameThirsty, thanks for answer.

    But maybe i wasn't clear.

    I don't need to open a simple url in simple new page.

    I know well how to code javascript :-)

    What i really need is this :


    (please look at javascript+html tab, it's clerarer)

    incapsulated in my C2 App.

    Thanks :)


  • Bump !


  • I had another idea.

    Using the object browser.executeJS can i execute "LINE BY LINE" the following instructions ?

    // Note: This example requires that you consent to location sharing when

    // prompted by your browser. If you see a blank space instead of the map, this

    // is probably because you have denied permission for location sharing.

    var map;

    function initialize() {

    var mapOptions = {

        zoom: 6


    map = new google.maps.Map(document.getElementById('map-canvas'),


    // Try HTML5 geolocation

    if(navigator.geolocation) {

        navigator.geolocation.getCurrentPosition(function(position) {

          var pos = new google.maps.LatLng(position.coords.latitude,


          var infowindow = new google.maps.InfoWindow({

            map: map,

            position: pos,

            content: 'Location found using HTML5.'



        }, function() {



    } else {

        // Browser doesn't support Geolocation




    function handleNoGeolocation(errorFlag) {

    if (errorFlag) {

        var content = 'Error: The Geolocation service failed.';

    } else {

        var content = 'Error: Your browser doesn\'t support geolocation.';


    var options = {

        map: map,

        position: new google.maps.LatLng(60, 105),

        content: content


    var infowindow = new google.maps.InfoWindow(options);



    google.maps.event.addDomListener(window, 'load', initialize);

    And then, how can i translate the html declarations :

    1) <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=true"></script>


    2) <body>

        <div id="map-canvas"></div>



    Thanks, hope i'm clear :)

  • BUMP !


    Is this request so impossible to fulfill ???

    Don't understand.



  • bump

  • bump ! I'm still stuck !

    I ask for help, i trusted scirra and have paid for full version.

    But support si quite lacking for my needings.

    What's wrong with me ?


  • Tom



  • Super BUMP !


  • themacvictror

    Did you see this ?

    I just released a little update but just think about this version may be somehow buggy - I have to do a new stable version of it but have no time for now

    Hopefully this is what you need

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)