-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deprecation on AjaxGMap, and commit of new CCGoogleMap
AjaxGMap and AjaxGMarker rely on Google Maps API V2 witch is deprecated too. The new CCGoogleMap and CCGoogleMapMarker uses google API V3 Signed-off-by: Amedeo Mantica <[email protected]>
- Loading branch information
Amedeo Mantica
committed
Apr 23, 2012
1 parent
2958b3d
commit 4bbd10c
Showing
7 changed files
with
279 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<wodefinitions> | ||
<wo wocomponentcontent="false" class="CCGoogleMap.java"> | ||
|
||
</wo> | ||
</wodefinitions> |
18 changes: 18 additions & 0 deletions
18
Frameworks/Ajax/ERCoolComponents/Components/CCGoogleMapMarker.api
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<wodefinitions> | ||
<wo class="CCGoogleMap.java" wocomponentcontent="false"> | ||
|
||
<binding name="id"/> | ||
<binding name="style"/> | ||
<binding name="class"/> | ||
<binding name="googleMapId"/> | ||
<validation message="'googleMapId' is a required binding."> | ||
<unbound name="googleMapId"/> | ||
</validation> | ||
<binding name="lat"/> | ||
|
||
<binding name="lng"/> | ||
|
||
<binding name="address"/> | ||
</wo> | ||
</wodefinitions> |
125 changes: 125 additions & 0 deletions
125
Frameworks/Ajax/ERCoolComponents/Sources/er/coolcomponents/CCGoogleMap.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
package er.coolcomponents; | ||
|
||
import org.apache.log4j.Logger; | ||
|
||
import com.webobjects.appserver.WOActionResults; | ||
import com.webobjects.appserver.WOAssociation; | ||
import com.webobjects.appserver.WOContext; | ||
import com.webobjects.appserver.WOElement; | ||
import com.webobjects.appserver.WORequest; | ||
import com.webobjects.appserver.WOResponse; | ||
import com.webobjects.appserver._private.WODynamicElementCreationException; | ||
import com.webobjects.foundation.NSDictionary; | ||
|
||
import er.ajax.AjaxDynamicElement; | ||
import er.ajax.AjaxUtils; | ||
import er.extensions.foundation.ERXProperties; | ||
|
||
/** | ||
* WebObjects wrapper for INGoogleMap.js. | ||
* | ||
* <p> | ||
* CCGoogleMap replaces AjaxGmap and will allow you to easily insert a google map inside your page</p> | ||
* <p> | ||
* You must set the property ajax.google.maps.V3.apiKey in your Properties file</p> | ||
* | ||
* <p>please note that is REQUIRED to set the widht height of the map, you can use id, class, or style to do that</p> | ||
* | ||
* @binding id the id of the div element that CCGoogleMap will generate | ||
* @binding class the class of the div element | ||
* @binding style the style of the div element | ||
* @binding zoom the desidered map startup zoom level | ||
* @binding lat the latidude of the map center | ||
* @binding lng the longitude of the map center | ||
* @binding type, can be ROADMAP, SATELLITE, HYBRID or TERRAIN, default to ROADMAP. all uppercase string | ||
* | ||
* | ||
* @see <a href="https://github.com/amedeomantica/INWebTools">INWebTools</a> | ||
* | ||
* @author amedeomantica (WebObjects wrapper and INGoogleMap.js) | ||
*/ | ||
|
||
public class CCGoogleMap extends AjaxDynamicElement { | ||
//private static Logger log = Logger.getLogger(CCGoogleMap.class); | ||
|
||
private WOAssociation _elementId; | ||
private WOAssociation _elementClass; | ||
private WOAssociation _elementStyle; | ||
private WOAssociation _zoom; | ||
private WOAssociation _type; | ||
private WOAssociation _lat; | ||
private WOAssociation _lng; | ||
|
||
public CCGoogleMap(String aName, NSDictionary someAssociations, | ||
WOElement template) { | ||
super(aName, someAssociations, template); | ||
|
||
_elementId = (WOAssociation) someAssociations.objectForKey("id"); | ||
_elementStyle = (WOAssociation) someAssociations.objectForKey("style"); | ||
_elementClass = (WOAssociation) someAssociations.objectForKey("class"); | ||
|
||
_zoom = (WOAssociation) someAssociations.objectForKey("zoom"); | ||
_type = (WOAssociation) someAssociations.objectForKey("type"); | ||
_lat = (WOAssociation) someAssociations.objectForKey("lat"); | ||
_lng = (WOAssociation) someAssociations.objectForKey("lng"); | ||
|
||
if( (_lat == null )||( _lng == null ) ) { | ||
throw new WODynamicElementCreationException("Unable to create CCGoogleMap, missing coordinates"); | ||
} | ||
|
||
} | ||
|
||
@Override | ||
public void appendToResponse(WOResponse response, WOContext context) { | ||
super.appendToResponse(response, context); | ||
AjaxUtils.addScriptCodeInHead(response, context, "var in_googleApiKey=\"" + | ||
ERXProperties.stringForKey("ajax.google.maps.V3.apiKey") + "\""); | ||
|
||
response.appendContentString("<div "); | ||
|
||
if(_elementId != null) { | ||
response.appendContentString("id=\"" + _elementId.valueInComponent(context.component()) + "\" "); | ||
} | ||
|
||
String classValue = "in_GoogleMap "; | ||
if(_elementClass != null) { | ||
classValue = classValue + (String)_elementClass.valueInComponent(context.component()); | ||
} | ||
response.appendContentString("class=\"" + classValue + "\" "); | ||
|
||
if(_elementStyle != null) { | ||
response.appendContentString("style=\"" + _elementStyle.valueInComponent(context.component()) + "\" "); | ||
} | ||
|
||
String zoomValue = "14"; | ||
if(_zoom!=null) { | ||
zoomValue = (String) _zoom.valueInComponent(context.component()); | ||
} | ||
response.appendContentString("data-zoom=\"" + zoomValue + "\" "); | ||
|
||
String mapType = "ROADMAP"; | ||
if(_type!=null) { | ||
mapType = (String) _type.valueInComponent(context.component()); | ||
} | ||
|
||
response.appendContentString("data-type=\"" + mapType + "\" "); | ||
response.appendContentString("data-lng=\"" + _lng.valueInComponent(context.component()) + "\" "); | ||
response.appendContentString("data-lat=\"" + _lat.valueInComponent(context.component()) + "\""); | ||
|
||
response.appendContentString("></div>"); | ||
} | ||
|
||
|
||
@Override | ||
protected void addRequiredWebResources(WOResponse response,WOContext context) { | ||
addScriptResourceInHead(context, response, "ERCoolComponents", "INGoogleMaps.min.js"); | ||
} | ||
|
||
|
||
@Override | ||
public WOActionResults handleRequest(WORequest request, WOContext context) { | ||
// TODO Auto-generated method stub | ||
return null; | ||
} | ||
|
||
} |
119 changes: 119 additions & 0 deletions
119
Frameworks/Ajax/ERCoolComponents/Sources/er/coolcomponents/CCGoogleMapMarker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
package er.coolcomponents; | ||
|
||
import com.webobjects.appserver.WOActionResults; | ||
import com.webobjects.appserver.WOAssociation; | ||
import com.webobjects.appserver.WOContext; | ||
import com.webobjects.appserver.WOElement; | ||
import com.webobjects.appserver.WORequest; | ||
import com.webobjects.appserver.WOResponse; | ||
import com.webobjects.foundation.NSDictionary; | ||
|
||
import er.ajax.AjaxDynamicElement; | ||
|
||
/** | ||
* WebObjects wrapper for INGoogleMap.js. | ||
* | ||
* <p> | ||
* CCGoogleMapMarker replaces AjaxGmapMarker and will allow you to easily insert one or more google markers inside a CCGoogleMap inside your page</p> | ||
* | ||
* <p>CCGoogleMapMarker will also insert an html address element on the page, | ||
* the content of CCGoogleMapMarker wil be copied inside the ballon thet people wil see clicking on the marker | ||
* if you don't want the address element to be shown on page simply set display none using css (id, class or style)</p> | ||
* | ||
* @binding id the id of the address element that CCGoogleMapMarker will generate | ||
* @binding class the class of the address element | ||
* @binding style the style of the address element | ||
* @binding googleMapId REQUIRED the id of the google map where you want the marker to be placed | ||
* @binding lat the latidude of the marker | ||
* @binding lng the longitude of the marker | ||
* | ||
* | ||
* @see <a href="https://github.com/amedeomantica/INWebTools">INWebTools</a> | ||
* | ||
* @author amedeomantica (WebObjects wrapper and INGoogleMap.js) | ||
*/ | ||
|
||
public class CCGoogleMapMarker extends AjaxDynamicElement { | ||
|
||
private WOAssociation _elementId; | ||
private WOAssociation _elementClass; | ||
private WOAssociation _elementStyle; | ||
private WOAssociation _googleMapId; | ||
private WOAssociation _draggable; | ||
private WOAssociation _lat; | ||
private WOAssociation _lng; | ||
private WOElement _children; | ||
|
||
public CCGoogleMapMarker(String name, | ||
NSDictionary<String, WOAssociation> someAssociations, WOElement children) { | ||
super(name, someAssociations, children); | ||
|
||
_elementId = (WOAssociation) someAssociations.objectForKey("id"); | ||
_elementStyle = (WOAssociation) someAssociations.objectForKey("style"); | ||
_elementClass = (WOAssociation) someAssociations.objectForKey("class"); | ||
|
||
_googleMapId = (WOAssociation) someAssociations.objectForKey("googleMapId"); | ||
_draggable = (WOAssociation) someAssociations.objectForKey("draggable"); | ||
_lat = (WOAssociation) someAssociations.objectForKey("lat"); | ||
_lng = (WOAssociation) someAssociations.objectForKey("lng"); | ||
|
||
_children = children; | ||
} | ||
|
||
@Override | ||
public void appendToResponse(WOResponse response, WOContext context) { | ||
// We need to call these otherwise the method "addRequiredWebResources" would not be called | ||
super.appendToResponse(response, context); | ||
|
||
response.appendContentString("<address "); | ||
|
||
if(_elementId != null) { | ||
response.appendContentString("id=\"" + _elementId.valueInComponent(context.component()) + "\" "); | ||
} | ||
|
||
String classValue = "in_GoogleMapMarker "; | ||
if(_elementClass != null) { | ||
classValue = classValue + (String)_elementClass.valueInComponent(context.component()); | ||
} | ||
response.appendContentString("class=\"" + classValue + "\" "); | ||
|
||
if(_elementStyle != null) { | ||
response.appendContentString("style=\"" + _elementStyle.valueInComponent(context.component()) + "\" "); | ||
} | ||
|
||
response.appendContentString("data-in_GoogleMap-id=\"" + _googleMapId.valueInComponent(context.component()) + "\" "); | ||
|
||
String draggable = "false"; | ||
if(_draggable!=null) { | ||
draggable = (String) _draggable.valueInComponent(context.component()); | ||
} | ||
|
||
response.appendContentString("data-draggable=\"" + draggable + "\" "); | ||
|
||
response.appendContentString("data-lng=\"" + _lng.valueInComponent(context.component()) + "\" "); | ||
response.appendContentString("data-lat=\"" + _lat.valueInComponent(context.component()) + "\""); | ||
|
||
response.appendContentString(">"); | ||
|
||
_children.appendToResponse(response, context); | ||
|
||
response.appendContentString("</address>"); | ||
|
||
} | ||
|
||
|
||
@Override | ||
protected void addRequiredWebResources(WOResponse response, | ||
WOContext context) { | ||
|
||
addScriptResourceInHead(context, response, "ERCoolComponents", "INGoogleMaps.min.js"); | ||
|
||
} | ||
|
||
@Override | ||
public WOActionResults handleRequest(WORequest request, WOContext context) { | ||
// TODO Auto-generated method stub | ||
return null; | ||
} | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
Frameworks/Ajax/ERCoolComponents/WebServerResources/INGoogleMaps.min.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.