[HEEEEELP !!!!!!] Google Maps

Get help using Construct 2

Post » Sun Dec 29, 2013 10:59 pm

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 !

TheMacthemacvictror2014-01-28 10:34:13
B
7
S
1
Posts: 38
Reputation: 491

Post » Mon Dec 30, 2013 12:11 am

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.GameThirsty2013-12-30 00:12:43
B
18
S
6
Posts: 348
Reputation: 2,633

Post » Thu Jan 02, 2014 5:59 am

@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;
control.map.setCenter(myLatLng);
});

---

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


TheMac
B
7
S
1
Posts: 38
Reputation: 491

Post » Fri Jan 10, 2014 9:30 pm

@GameThirsty

what's wrong with my code? :(

vvv(dot)dropbox(dot)com/s/t47halr821hz0ij/testmap.capx

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


Thanks.

TheMac
B
7
S
1
Posts: 38
Reputation: 491

Post » Tue Jan 14, 2014 8:00 am

@GameThirsty

UP ?

TheMac
B
7
S
1
Posts: 38
Reputation: 491

Post » Tue Jan 14, 2014 4:54 pm

@themacvictor

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.GameThirsty2014-01-14 16:58:18
B
18
S
6
Posts: 348
Reputation: 2,633

Post » Wed Jan 15, 2014 8:06 am

@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 :
https://developers.google.com/maps/documentation/javascript/examples/map-simple

(please look at javascript+html tab, it's clerarer)
incapsulated in my C2 App.

Thanks :)

TheMacthemacvictror2014-01-15 08:07:12
B
7
S
1
Posts: 38
Reputation: 491

Post » Mon Jan 20, 2014 8:48 am

Bump !

TheMac
B
7
S
1
Posts: 38
Reputation: 491

Post » Mon Jan 20, 2014 11:29 am

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'),
      mapOptions);

// Try HTML5 geolocation
if(navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function(position) {
      var pos = new google.maps.LatLng(position.coords.latitude,
                                       position.coords.longitude);

      var infowindow = new google.maps.InfoWindow({
        map: map,
        position: pos,
        content: 'Location found using HTML5.'
      });

      map.setCenter(pos);
    }, function() {
      handleNoGeolocation(true);
    });
} else {
    // Browser doesn't support Geolocation
    handleNoGeolocation(false);
}
}

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);
map.setCenter(options.position);
}

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>

and

2) <body>
    <div id="map-canvas"></div>
</body>


?

Thanks, hope i'm clear :)



B
7
S
1
Posts: 38
Reputation: 491

Post » Tue Jan 21, 2014 9:30 am

BUMP !

@Ashley

Is this request so impossible to fulfill ???


Don't understand.

Thanks.

TheMac
B
7
S
1
Posts: 38
Reputation: 491

Next

Return to How do I....?

Who is online

Users browsing this forum: Anna Nehves Br, divsyntax, volumetv and 16 guests