Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo

Google Mapping questions


Go to End


8 Posts   3529 Views

Avatar
Sigurd

Forum Moderator, 628 Posts

13 July 2007 at 1:07pm

Edited: 13/07/2007 1:23pm

Ofir, can you explain why you need to force dev mode and disable the content negotiator in the google maps _config.php?

I'm going to remove devmode but perhaps leave contentneg in, for the preliminary 0.1 release... ?

I'll also remove the API key so that much of the code is disabled until you actually enter in a key. Since the one you bundle will never work for anyone else. This makes the _config.php like this:

<?php
// Enter your free GoogleMaps API key from http://code.google.com/apis/maps/signup.html
$GMaps_API_Key = '';
/**
 * TODO: Need a better place to handle this. We should be able to set that from
 * the sites _config.php file rather than in here
 */


ContentNegotiator::disable();
Requirements::css("maps/css/Maps.css");
Requirements::javascript("http://maps.google.com/maps?file=api&v=2.x&key=".$GMaps_API_Key);
?>

Avatar
Sigurd

Forum Moderator, 628 Posts

13 July 2007 at 3:26pm

Edited: 13/07/2007 3:27pm

Seems to work for me, so I've uploaded. I then did the following to test the release was sweet. Please let me know if anyone finds a problem!

Note that forum0.11 adds support for googlemaps, the 0.1 release will function as a forum but not show any google maps.

wget http://www.silverstripe.com/assets/downloads/modules/forum-0.11.tar.gz
wget http://www.silverstripe.com/assets/downloads/modules/maps-0.1.tar.gz
wget http://www.silverstripe.com/assets/rc/silverstripe-v2.0.2-rc3.tar.gz

tar xzf http://www.silverstripe.com/assets/rc/silverstripe-v2.0.2-rc3.tar.gz
cd silverstripe-v2.0
tar xzf ../maps-0.1.tar.gz
tar xzf ../forum-0.11.tar.gz

Add API to to maps/_config.php, get one from http://code.google.com/apis/maps/signup.html

chmod g+w .htaccess tutorial mysite assets

( visit the installer )

( go into cms and add a "ForumMemberMap" page)

Avatar
Sigurd

Forum Moderator, 628 Posts

13 July 2007 at 4:18pm

Edited: 13/07/2007 4:18pm

Ofir, you're requirement of:

Requirements::css("maps/css/Maps.css");

Stuffs up the CMS login page. This will be partly solved by only including it on pages where googlemaps are included. (This affects the version of the code that is now for public download, so please fix and commit to SVN :) )

Secondly, I noticed that Requirements::javascript() needs to produce XML-safe code; as it stands if you remove your phrase "Requirements::javascript("http://maps.google.com/maps?file=api&v=2.x&key=".$GMaps_API_Key);" then you get an XML-not-well formed error on the equals sign.

Avatar
Sigurd

Forum Moderator, 628 Posts

13 July 2007 at 4:39pm

See attached

Avatar
elijahlofgren

Google Summer of Code Hacker, 222 Posts

14 July 2007 at 4:42pm

Good job Ofir! Keep up the great work!

I tested maps-0.1 with silverstripe-v2.0.2-rc3 and forum-0.11 on Apache 1.3.37 (Unix), MySQL 5.0.27-standard, and PHP version 5.2.3 and everything works great.

It would be cool to be able to select a more specific location on the map by clicking on a specific point or by choosing a state. But I'm sure stuff like that is planned for later. :)

Have a great weekend,

Elijah

Avatar
Sigurd

Forum Moderator, 628 Posts

15 July 2007 at 12:07am

Instead of only dragging it, you mean? I just want to confirm that you were able to move your map point ....

Avatar
elijahlofgren

Google Summer of Code Hacker, 222 Posts

15 July 2007 at 5:32am

> Instead of only dragging it, you mean? I just want to confirm that you were able to move your map point ....

Ah, I didn't realize you could do that. I had only tried double-clicking where I wanted the point.

Maybe instructions like "Drag and drop the marker to your location" should be added.

Cheers,

Elijah

Avatar
xmedeko

Community Member, 94 Posts

7 August 2007 at 4:07pm

Edited: 07/08/2007 4:08pm

for dblclick to set the location, try something like
[code javascript/]
GEvent.addListener(map, "dblclick", function(overlay, point) {
marker.setPoint(point);
document.getElementById("{$this->name}_latitude").value = point.lat();
document.getElementById("{$this->name}_longitude").value = point.lng();
});