Hi I m trying to migrate a google maps V2 to google maps V3 project.
Here I m creating a prototype as below.It is in a seperate .js file other than the .js file containing function to initialize the map.
Ubicacion.prototype = new google.maps.Overlay();
Ubicacion.prototype.initialize = function(map) {
var alias_ = this.alias_;
var direccion_ = this.direccion_;
var fecha_ = this.fecha_;
var point_ = this.point_;
var tipo_ = this.tipo_;
var imagen_ = this.imagen_;
...
}
But I m getting "google.maps.Overlay is not a constructor". I understand by googling that it may be caused because initialization is happening before google maps is being loaded; and can be rectified by using google.setOnLoadCallback() for initizialising objects.But I m not very clear in using the same.
Can any one please guide me?This is very urgent.
There really is no such constructor.
I guess what you try to use should be google.maps.OverlayView
Related
Is there any way to read and display the photographer's name in Google Maps Business View using Google Maps Javascript API v3? I can't find any hint in the reference and I don't get the problem solved.
Thanks, Stefan
You could use the #copyright param from the panorama.
https://developers.google.com/maps/documentation/javascript/reference#StreetViewPanoramaData
For example you could do this:
var center = new google.maps.LatLng(-31.416676, -64.1841580000002);
var streetViewService = new google.maps.StreetViewService (document.getElementById("map"));
streetViewService.getPanoramaByLocation(center, 30, function(panorama){console.log(panorama.copyright);});
This would create a new instance of streetViewService, then you ask for the panorama related to the "center" variable and finally, you could use the copyright variable.
Also, you could use just the description field from the location variable returned from the same getPanoramaByLocation call:
var center = new google.maps.LatLng(-31.416676, -64.1841580000002);
var streetViewService = new google.maps.StreetViewService (document.getElementById("map"));
streetViewService.getPanoramaByLocation(center, 30, function(panorama){console.log(panorama.location.description);});
Hope it helps.
I want to share a document with JavaScript and get its share_id programatically.
There is a REST API that can do that but I didn't know how to call it from script.
Any clues?
The following hack will do the trick. (edit: Must be executed from the classpath in the repository)
var ctx = Packages.org.springframework.web.context.ContextLoader.getCurrentWebApplicationContext();
var qsService = ctx.getBean("QuickShareService");
var sId = document.properties['qshare:sharedId'];
if (!sId) {
sId = qsService.shareContent(document.nodeRef).id;
}
PS: It looks even more ugly on 5.0.a due to rhino-1.7.
I want to represent 3D models in Google Earth environmente with API and Google Plugin.
I have the code:
var ge;
google.load("earth", "1");
function init() {
google.earth.createInstance('map3d', initCB, failureCB);
}
function initCB(instance) {
ge = instance;
ge.getWindow().setVisibility(true);
ge.getNavigationControl().setVisibility(ge.VISIBILITY_HIDE);
// Placemark
var placemark = ge.createPlacemark('Modello1');
placemark.setName('model');
var place2 = ge.createPlacemark('Modello2');
place2.setName('modello2');
// Placemark/Model (geometry)
var model = ge.createModel('Mod1');
placemark.setGeometry(model);
var modello2 = ge.createModel('Mod2');
place2.setGeometry(modello2);
// Placemark/Model/Link
var link = ge.createLink('File1');
link.setHref("http://myhost.org/table2/models/table2.dae");
model.setLink(link);
var link2 = ge.createLink('File2');
link2.setHref("http://myhost.org/tavolo/models/table2.dae");
modello2.setLink(link2);
// get center look at location
var lookAt = ge.getView().copyAsLookAt(ge.ALTITUDE_RELATIVE_TO_GROUND);
// Placemark/Model/Location
var loc = ge.createLocation('');
loc.setLatitude(40.01000594412381);
loc.setLongitude(-105.2727379358738);
model.setLocation(loc);
//slightly varying coordinates...
var loc2 = ge.createLocation('');
loc2.setLatitude(40.01000594412389);
loc2.setLongitude(-105.2727379358731);
modello2.setLocation(loc2);
// add the model placemark to Earth
ge.getFeatures().appendChild(placemark);
ge.getFeatures().appendChild(place2);
// zoom into the model
lookAt.setLatitude(40.01000594412381);
lookAt.setLongitude(-105.2727379358738);
lookAt.setRange(300);
lookAt.setTilt(80);
ge.getView().setAbstractView(lookAt);
}
function failureCB(errorCode) {
}
google.setOnLoadCallback(init);
When i load different collada (.dae) files no problems appear... but it doesn't load the same Table 2 times! Why?!?
I have also tried to separate instances and files... but problem persists. I have only one table on my environment.
Is there a method to clone single model into N models ?
have you tried injecting kml t display the models using parse kml.
also try using getKml to get the kml and see if it renders properly in a stand alone kml file
I am using Subgurim asp.net control for Google Maps in ASP.net.
The Problem is that I need to show an ARROWED POLYLINE betwwen my two points on map.
Following is my code , but unfortunately I am not able to apply anything for that:
GLatLng from = new GLatLng(FromLan, FromLon);
GLatLng To = new GLatLng(ToLan, ToLon);
GLatLngBounds llbound = new GLatLngBounds(from, To);
GMap2.GZoom = GMap2.getBoundsZoomLevel(llbound);
GMap2.setCenter(llbound.getCenter());
GLatLng inside = llbound.getCenter();
bool isInside = llbound.contains(inside);
GPolyline objpolyline = new GPolyline();
objpolyline.points.Add(from);
objpolyline.points.Add(To);
objpolyline.color = "red";
objpolyline.colorNet = System.Drawing.Color.Red;
objpolyline.clickable = false;
objpolyline.PolylineID = "Route";
objpolyline.geodesic = true;
//Javascript Code
//pts1.push (new GLatLng(lat111, lng222));
//var poly1 = new BDCCArrowedPolyline(pts1,"#FF0000",4,0.3,
// null,30,7,"#0000FF",2,0.5);
//map.addOverlay(poly1);
GMap2.addPolyline(objpolyline);
//GMap2.addPolyline(objpolyline);
Regards ,
Vishal
It looks to me like you are using the Google Maps API v2.
Two issues with that:
it is deprecated and could stop working in less than a year.
the Google Maps API v3 now supports "arrowed polylines" natively.
is it possible to embed sources dynamically. instead of doing this
[Embed(source = '../../../../assets/levels/test.xml')]
I could probably do something like this
var src = '../../../../assets/levels/test.xml'
[Embed(source = src )]
It's not possible for anything within metadata annotations to be dynamic :/. That is, you can't place variables into metadata annotations. If that was possible, there would be SO many cool possibilities. So your first option is the only way to directly embed xml.
You could, however, write a custom metadata parser that figured out how to load (not embed) your xml file. Something like:
[LoadFile]
public var source:String = "../../../../assets/levels/test.xml";
I would implement that like the code below (just wrote this right now, haven't tested it). And then you'd "process" your class via something like MyMetadataUtil.process(this). Lots of ways to do that.
public function extractMetadata(target:Object):void
{
var description:XML = flash.utils.describeType(target);
var tag:String = "LoadFile"
var metadata:XMLList = description.accessor.metadata.(#name == tag);
metadata += description.variable.metadata.(#name == tag);
var i:int = 0;
var n:int = metadata.length();
// usually called a 'directive'
// holds values from metadata annotation
var token:Object = {};
for (i; i < n; i++)
{
metadataXML = metadata[i];
token.property = metadataXML.parent().#name;
// token.source = myClass.source;
token.source = target[token.property];
var request:URLRequest = new URLRequest(token.source);
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, loader_completeHandler);
loader.addEventListener(IOErrorEvent.IO_ERROR, loader_ioErrorHandler);
loader.load(request);
}
}
protected function loader_completeHandler(event:Event):void
{
event.currentTarget.removeEventListener(event.type, loader_completeHandler);
trace("SUCCESSFULLY LOADED FILE!");
}
protected function loader_ioErrorHandler(event:Event):void
{
event.currentTarget.removeEventListener(event.type, loader_ioErrorHandler);
}
That stuff would go into some util/manager/processor class. Then anywhere in your code, you could use this:
[LoadFile]
public var source:String = "myFile.xml";
And that could be dynamic. Check out the Swiz Framework for some example source code on how to implement custom metadata processors. Or even better, Openflux's MetaUtil. Once you set that up once, you can do some hardcore stuff in your code. Makes coding fun and fast.
Hope that helps,
Lance
Your use case is basically why I created the ability to add extra frames to Flex SWFs that are treated as late-loaded modules. Instead of embedding your level, stream it in after the main application.
Documentation on -frame is sparse. Sorry! Here's some external stuff, that links back to stuff I wrote and Alex Harui wrote. Good luck!
http://www.richinternet.de/blog/index.cfm?entry=FF295F89-DAD8-CCDC-960413842BC0D478