[View]  [Edit]  [Lock]  [References]  [Attachments]  [History]  [Home]  [Changes]  [Search]  [Help] 

api[web,google,maps] code

NativeLibraryObject
 subclass: #GoogleMaps
 instanceVariableNames: ''
 category: #GoogleMaps!
GoogleMaps comment: '
	Root of Google Maps API framework.
	@2012 Alejandro Reimondo - [email protected]
'!

! GoogleMaps class methodsFor: #private !
library
	" Private - Return the Google's library for maps. "

	| result |
	result := self libraryOrNil.
	result isNil ifTrue: [ ^self error: 'Missing Google Maps library.' ].
	^result! !

! GoogleMaps class methodsFor: #private !
libraryOrNil
	" Private - Return the Google's library for maps.
	It is assumed that the GoogleMap library is already loaded and enabled/registered.
	"

	^google notNil ifTrue: [ google#maps ]! !

! GoogleMaps class methodsFor: #private !
onLoad: aBlock
	" Private - Load the library of the receiver and evaluates aBlock. "

	self invalidMessage: #onLoad:! !

! GoogleMaps class methodsFor: #private !
globalClassNameFrom: globalClassName
	" Private - Return the global class name for global globalClassName. "

	^(globalClassName indexOf: #Google) = 0
		ifTrue: [ globalClassName ]
		ifFalse: [ globalClassName copyFrom: 7 to: globalClassName size ]! !


"-----Google Maps API version 3.x implementation -------"!

GoogleMaps buildSubclasses: #(
	#( #GoogleMap #( element options ) #( element ))
	#( #LatLng #( x y ) )
	#( #Marker #( options ) #())
	#( #InfoWindow #( options ) #())
)!


! GoogleMap class methodsFor: 'instance creation' !
in: aDiv latitude: latitude longitude: longitude zoom: zoomFactor
	" Return an (open) instance of the receiver. "

	^self element: aDiv options: (
		 (#zoom -> zoomFactor)
		,(#center -> (LatLng x: latitude y: longitude))
		) json! !

	
! GoogleMap class methodsFor: #sample !
sample
	" SAMPLE - Open a sample map on playground "

	| div |
	div := U8 playground.
	div style
		position: #absolute;
		width: #100%; height: #50%;
		bottom: 0.

	self	in: div
		latitude:	-34.552
		longitude:	-58.47
		zoom:8! !